认证高级PHP讲师
box.getElementsByTagName('a')[0]
txt[0].style.display = 'none';
You wrote txt[0].style.color = '#f00' If it works Then you wrote txt.style.display = 'none' Don’t you feel awkward?
txt[0].style.color = '#f00'
txt.style.display = 'none'
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...
box.getElementsByTagName('a')[0]
txt[0].style.display = 'none';
You wrote
txt[0].style.color = '#f00'
If it worksThen you wrote
txt.style.display = 'none'
Don’t you feel awkward?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...