Accessing elements by type in javascript

后端 未结 4 665
逝去的感伤
逝去的感伤 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:09

    The sizzle selector engine (what powers JQuery) is perfectly geared up for this:

    var elements = $('input[type=text]');
    

    Or

    var elements = $('input:text');
    

提交回复
热议问题