how to select data attribute in javascript using queryselectorAll
<!DOCTYPE html>
<html>
<head></head>
<body>
<p data-foo="0"></p>
<h6 data-foo="1"></h6>
<script>
var a = document.querySelectorAll('[data-foo]');
for (var i in a) if (a.hasOwnProperty(i)) {
alert(a[i].getAttribute('data-foo'));
}
</script>
</body>
</html>
Also in JavaScript:
- jwt strategy
- get all parent nodes of child in javascript array
- change array index position in javascript by up and down click
- jasmine compare arrays
- onclick start and stop the count react
- c# print object to json
- string javascript concatenation
- js string insert space
- nodejs promise then example
- jquery alert
- scroll to top jquery
- eslint disable block
- reduce()
- javascript es6 class
- align left text in reactstrap
- wait for time javascript
- delete value from json array with index
- Difference in push and navigate in react Navigation
- get attribute value jquery
- jquery function
- discord bot remove message reaction
- react json object pretty
- gitignore for angular
- javascript reverse string