Skip to content
Advertisement

querySelectorAll selects all similar classes

Calendar is using 3 different classes to style its child elements: “old day”, “day”, “new day”. Trying to querySelectorAll element with class name “day” also captures the other two classes, so when i say something like:

JavaScript

I will get click on old 28th instead of current month 28th.

How do i select “day” class of td element without also selecting “old day” and “new day”?

Advertisement

Answer

You can use :not to specify which classes you don’t want to match.

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement