Accessing elements by type in javascript

后端 未结 4 669
逝去的感伤
逝去的感伤 2020-12-25 09:51

A while ago I was making some test in Javascript, and played with a code to get the text of all elements with a certain class, Now I was trying to make something like this

4条回答
  •  轮回少年
    2020-12-25 10:30

    If you are lucky and need to care only for recent browsers, you can use:

    document.querySelectorAll('input[type=text]')
    

    "recent" means not IE6 and IE7

提交回复
热议问题