Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to target html elements in javascript

// HOW TO GET ELEMENT BY CLASS

const gotIt = document.querySelector('.theElement');
//<p class="theElement">This is the element you are targeting.</p>    <----html

// HOW TO GET ELEMENT BY ID

const gotIt = document.querySelector("#get-residents")
//<button id="get-residents">get residents</button>              <---- html
 
PREVIOUS NEXT
Tagged: #target #html #elements #javascript
ADD COMMENT
Topic
Name
1+9 =