javascript - Why is setting the dipplay of a tag invalid in JS but valid in CSS?
PHP中文网
PHP中文网 2017-07-05 10:50:11
0
5
1020

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(5)
曾经蜡笔没有小新

box.getElementsByTagName('a')[0]

某草草

txt[0].style.display = 'none';

phpcn_u1582

You wrote txt[0].style.color = '#f00' If it works
Then you wrote txt.style.display = 'none' Don’t you feel awkward?

大家讲道理
document.getElementsByTagName('a')[0].style.display = "none";

What is set using getElementsByTagName is an array, so the value needs to be indexed

伊谢尔伦

getElementsByTagName is obtained from NodeList. You need to use subscripts to obtain a specific element. The txt you use is a nodelist, which is a list of multiple elements. Please refer to https://developer.mozilla.org...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template