No products in the cart.
Forum Replies Created
Viewing 1 post (of 1 total)
- AuthorPosts
-
etoxin
ParticipantNative JS Examples
Get NodeList of elements
var elem = document.querySelectorAll('[data-id="container"]')
html:
<div data-id="container"></div>
Get the first element
var firstElem = document.querySelector('[id="container"]')
html:
<div id="container"></div>
Target a collection of nodes which returns a nodelist
document.getElementById('footer').querySelectorAll('[data-id]')
html:
<div class="footer"> <div data-id="12"></div> <div data-id="22"></div> </div>
Get elements based on multiple (OR) data values
document.querySelectorAll('[data-section="12"],[data-selection="20"]')
html:
<div data-selection="20"></div> <div data-section="12"></div>
Get elements based on combined (AND) data values
document.querySelectorAll('[data-prop1="12"][data-prop2="20"]')
html:
<div data-prop1="12" data-prop2="20"></div>
Get items where the value starts with
document.querySelectorAll('[href^="https://"]')
- AuthorPosts
Viewing 1 post (of 1 total)