---
title: "Comment by Victor Neves on \"Separate your Javascript Access from CSS Selectors\" | Hashnode"
description: "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&#39;s better than targeting a"
url: "https://hashnode.com/posts/separate-your-javascript-access-from-css-selectors/601cce7d1054fa16dadd6db3/comment/601d0ad51054fa16dadd71f1"
---

[Discussion](https://hashnode.com/posts/separate-your-javascript-access-from-css-selectors/601cce7d1054fa16dadd6db3)

Comment [Separate your Javascript Access from CSS Selectors](https://hashnode.com/posts/separate-your-javascript-access-from-css-selectors/601cce7d1054fa16dadd6db3)

[Victor Neves](https://hashnode.com/@vneves)

[Feb 5, 2021](https://hashnode.com/posts/separate-your-javascript-access-from-css-selectors/601cce7d1054fa16dadd6db3/comment/601d0ad51054fa16dadd71f1)

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')
```

[Ayush Saini](https://hashnode.com/@AyushCodes)

[Feb 5, 2021](https://hashnode.com/posts/separate-your-javascript-access-from-css-selectors/601cce7d1054fa16dadd6db3/comment/601d0ad51054fa16dadd71f1#reply-601d6f6c1054fa16dadd7b47)

Indeed Victor, I too love to use that approach but what I realized is that selecting elements with data attributes can greatly improve the code readability and maintenance. Thanks for reading it 💖
