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
Post a Comment