javascript - How to select an item by attribute without jquery? -


i need select element this: $('[data-key=' + objectid + ']'), need select without jquery, using document.queryselector or else on pure js.

you can document.queryselectorall('[data-key=' + objectid + ']') , loop through results

var allkeys = document.queryselectorall('[data-key=' + objectid + ']');  [].foreach.call(allkeys, function(elem){    console.log(elem); //do stuff each element }); 

Comments

Popular posts from this blog

xml - Extract substrings with XSLT -

math - "ELO Rating" and how does "TSR Rating" work? -

How can do a tuple comparison in coffeescript similar to that in python? -