js select by data attribute
const link = document.querySelector('[data-link="1"]');
4.25
3
$('*[data-id="your_id"]');
Thank you!
3
0
4
3
<!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>
Thank you!
3
0
3.85
10
$("[attribute=value]")
Thank you!
10
0
Are there any code examples left?
New code examples in category Javascript