+ 2
Why there are somany other ways to get elements?
Why there are somany other ways to get elements even if there are Id(s), classes, first child etc....
2 Réponses
+ 4
In different situations you may need to use different ways. js makes it possible to reach the same element or elements with many functions
+ 2
There's a bunch of reasons. Example: Sometimes you need to target a parent of a particular element that is dynamic by selecting only if the element contains a certain string. You'd have to target only the parent of that particular element. However, as a best practice, when possible choose to select by ID rather than class as js can find the element fastest that way.