&nb">
84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
试了getElementsByName和getElementsByTagName都不行,只有getElementById可以,比如下面的例子
慕课网
Why can’t I change the color of text through getElementsTagName? -PHP Chinese website Q&A-Why can't I change the color of text through getElementsTagName? -PHP Chinese website Q&A
Please watch and learn.
getElementsByTagName获取的是数组。数组不能直接用style属性来设置的,用colour[0].style.color="red";可以实现
getElementsByName和getElementsByTagName获取的是一个由dom元素组成的数组。数组是无法直接用style属性来设置的,得先循环遍历这个数组,一项项取得dom元素再赋予style属性
Why can’t I change the color of text through getElementsTagName? -PHP Chinese website Q&A-Why can't I change the color of text through getElementsTagName? -PHP Chinese website Q&A
Please watch and learn.
getElementsByTagName获取的是数组。数组不能直接用style属性来设置的,用colour[0].style.color="red";可以实现
getElementsByName和getElementsByTagName获取的是一个由dom元素组成的数组。数组是无法直接用style属性来设置的,得先循环遍历这个数组,一项项取得dom元素再赋予style属性