js如何通过类名获得多个input对象

2024-10-11 20:13:13

1、新建一个html文件,命名为test.html,用于讲解js如何通过类名获得多个input对象。

js如何通过类名获得多个input对象

3、在test.html文件内,设置input标签的class属性为abc。

js如何通过类名获得多个input对象

5、在js标签内,再通过for循环遍历input对象,将每一个input的背景颜色设置为灰色。

js如何通过类名获得多个input对象
猜你喜欢