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 :: javascript reload page without refresh 
Javascript :: A simple static file server built with Node.js 
Javascript :: npm react dropdown 
Javascript :: passport local mongoose 
Javascript :: react js pdf generate from html 
Javascript :: what is jquery 
Javascript :: anagram program in javascript 
Javascript :: sentry ignoreerrors 
Javascript :: create react expo 
Javascript :: i want to redirect to main page from iframe javascript 
Javascript :: jquery use variable in string "without" concatenate 
Javascript :: import svg as react component 
Javascript :: randomize an array in javascript 
Javascript :: change the position of div using javascript 
Javascript :: ternary operator javascript 
Javascript :: htpp code 
Javascript :: How to check if an item is selected from an HTML drop down list with javascript js 
Javascript :: js object contains key 
Javascript :: jquery detect shift tab 
Javascript :: update node js 
Javascript :: reverse json.stringify 
Javascript :: javascript getdate 
Javascript :: jquery grab table row 
Javascript :: webpack file-loader 
Javascript :: sort method in js 
Javascript :: Quoting Strings with Single Quote 
Javascript :: json server paging 
Javascript :: state hook is not updating react 
Javascript :: react native password 
Javascript :: vue add external script 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =