Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

queryselectorall data attribute

document.querySelectorAll("[data-foo='1']")
Comment

queryselectorall in javascript to get data attribute value

//javascript get html data attribute
Comment

queryselectorall data attribute

document.querySelectorAll("[data-foo]")
Comment

PREVIOUS NEXT
Code Example
Javascript :: get next month js 
Javascript :: javascript ceiling 
Javascript :: date().toisostring().slice(0 10) giving wrong result 
Javascript :: db.json 
Javascript :: prompt box to integer 
Javascript :: call function after 2 seconds javascript 
Javascript :: loop through list js 
Javascript :: dotnet core ajax post of an ojject site:stackoverflow.com 
Javascript :: remove null values from json object in javascript 
Javascript :: eslint ignore current line 
Javascript :: angular version command 
Javascript :: bind to constructor 
Javascript :: sum an array in javascript 
Javascript :: js console log without spaces 
Javascript :: salut 
Javascript :: convert seconds to hours minutes seconds javascript 
Javascript :: dummy json 
Javascript :: Iterate Odd Numbers With a For Loop 
Javascript :: next js tailwind 
Javascript :: dynamic component angular parameters 
Javascript :: react native expo release apk 
Javascript :: image url to file js 
Javascript :: jshint es6 vscode 
Javascript :: react map 
Javascript :: React modal input field auto focus antd 
Javascript :: create react app in current folder 
Javascript :: how to create an invite discord.js 
Javascript :: observable.create is deprecated 
Javascript :: mathjs get element from matrix 
Javascript :: jquery ajax type json 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =