Answers for "select data attribute javascript"

0

how to select data attribute in javascript

const link = document.querySelector('[data-link="1"]');
Posted by: Guest on April-07-2021
5

html javascript find data attribute

//javascript get html data attribute
<button data-id="1" >Click</button>
<button data-id="2" >Click</button>
<button data-id="3" >Click</button>
const btns=document.querySelectorAll('button[data-id]');
[...btns].forEach(btn => console.log(btn.getAttribute('data-id')))
Posted by: Guest on July-25-2020
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
1

select by data attribute

$('*[data-id="your_id"]');
Posted by: Guest on September-10-2020
0

js select by data attribute

$("[attribute=value]")
Posted by: Guest on December-17-2020

Code answers related to "select data attribute javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language