Last active
June 8, 2022 06:32
-
-
Save celestial-labs/1d7e21149b348c8906a66803b60ee179 to your computer and use it in GitHub Desktop.
[js selector] #js #dom #javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const elem = document.getElementById( 'exampleDiv' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const elems = document.getElementsByClassName( 'example') | |
const elem = document.querySelector( 'img.class' ); | |
const elems = document.querySelectorAll( 'img.class, #id1' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const elems = document.getElementsByTagName( 'div' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="div1"> | |
<div id="div2"> | |
<div id="div3"> Some text here </div> | |
</div> | |
</div> | |
<script> | |
const div3 = document.getElementById( 'div3' ); | |
const div2 = div3.parentNode; | |
const div1 = div2.parentNode; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment