Do you use CSS selectors like classes or id's to select the HTML elements on the Document Object Model? If yes, then get ready to learn an more intuitive way to select the DOM elements because in this article we will be learning about how and why to ...

Markdown supported · ⌘↵ to post
I use a different approach with a js prefix class. Attributes should be used to pass data and not for targeting element even so it's better than targeting an ID or a CSS class.
e.g:
<button class="js-percentage-button btn-red">%</button>
const percentageButton = document.querySelector('.js-percentage-button')
Thanks for sharing, I recently ran into an issue where I had to change my class name in both my HTMl and JS file. Now I'll use the data- attribute instead.
Also I like the way you write 😊, easily to understand 👍
Very interesting topic, But don't you think that just by adding another class name only for JavaScript selector, give you the same approach?, thanks.
Wow, amazing content and representations as well. I was feeling like you're talking when you used "not convinced Ayush"
Catalin Pit
Great article!
P.S: I also love the article image!