Notes
The DOM - Selecting Elements
Content of the notes (1)
Page 1
The javascript file need to be taged before the closing body tag in the HTML code in a <script> tag.
There is a another way to load js file on the page: putting all the js code inside of a function and then adding an event listener that listens for the DOM content loaded event runs the init() function we created when that happens. This way, the script tag can be placed in the head tag and or page will still run.
We can use querySelector() and querySelectorAll() to select a CSS selector (how argument on the method) and listen for clicks, change the content , add content and etc.
The way we use to select CSS selectors is using its name with the symbol that represents the type of selector. Like '.' to classes and '#' to IDs. Or we can still just take a tag name or anything else in HTML code.
Information
- Description
- Técnico Web Development - Javascript Note on The DOM - Selecting Elements, created by Eduardo Souza on 06/01/2022.
- Created by
- Eduardo Souza
- Views
- 0
- Tags
- Rating