Answers for "js queryselectorall data atrtr"

0

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>
Posted by: Guest on December-06-2020
0

js queryselectorall

elementList = parentNode.querySelectorAll(selectors);
Posted by: Guest on January-12-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language