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

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -