How to select all DOM elements that have a certain class but also have certain CSS attribute value using JavaScript?
For example, I want to select all the elements that have class "date" but have a display: none CSS attribute.
I know it has something to do with querySelector / querySelectorAll but I am unable to find such example (all the examples I stumbled upon either select by class or by CSS attribute but not by both).
>Solution :
you can do this by combining the class selector with the attribute selector in the querySelector(All) method. Here is how you can select all elements with the class date and a CSS attribute display: none for example.
const elements = document.querySelectorAll('.date[style*="display: none"]');