Having spent the last 3 years gradually improving my javascript, I am now learning the jQuery shorthand equivalents.
I have long been aware that jQuery's clever selectors can now be achieved in native Javascript using:
document.querySelector();
document.querySelectorAll();
However, in solving a recent problem, I used the following selector in jQuery:
$('div div[class!="class4"]')
When I tried to duplicate in Javascript what I'd successfully achieved in jQuery, I used the same selector:
document.querySelectorAll('div div[class!="class4"]')
But it didn't work!
Then I checked several authoritative CSS sources for the [attribute != "value"]
and I couldn't find mention of it anywhere.
I am happy to use
document.querySelectorAll('div div:not(.class4)')
in Javascript instead.
But... what about [attribute != "value"]
?
Have I made it up?
And if so, why does it work in jQuery?