I am here to tell you that there is hope on the horizon. No matter the chosen route, good logic can yield the desired result.
This “selection” can be done in many different ways:
- we can get elements by id:
- we can get elements by class name:
- we can get elements by tag name:
- we can also get any of the above elements by query selector:
with querySelector we can replace any of the other methods for ‘getting’ an element. The ‘#’ represents id, ‘ . ’ represents class and nothing in front will represent the tag. The most important thing to remember is that querySelector will only grab the first element it finds as its searching through the document.
- if you want to select multiple ‘li’ tags, for example, you can querySelectorAll:
Some of the the things you can do include:
- creating new elements that can be appended (inserted) inside these elements
- changing the inner text of the elements
- listening for ‘events’ on the elements. Events can be a click, submit, hover, or any other form of user action that can be done on a page.
- forms can be built inside the elements
- classes or ids can be added or changed on the element