search

Home  >  Q&A  >  body text

javascript - Why is setting the dipplay of a tag invalid in JS but valid in CSS?

PHP中文网PHP中文网2697 days ago1021

reply all(5)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-07-05 10:52:11

    box.getElementsByTagName('a')[0]

    reply
    0
  • 某草草

    某草草2017-07-05 10:52:11

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

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-07-05 10:52:11

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

    reply
    0
  • 大家讲道理

    大家讲道理2017-07-05 10:52:11

    document.getElementsByTagName('a')[0].style.display = "none";

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

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-07-05 10:52:11

    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...

    reply
    0
  • Cancelreply