I've been attempting to find a way to replace the jQuery .not()
function with native JavaScript, but so far my attempts using document.querySelectorAll
have not been successful.
Here is what I am trying to achieve - converting this jQuery selector into vanilla JS:
$('#someID').not('.classNameOne > div, .classNameTwo > div, div[class*="-something"] > div')
My attempt involved using this simple selector:
document.querySelectorAll("#someID:not(.classNameOne > div, .classNameTwo > div, div[class*="-something"] > div)");
However, this resulted in an error:
Uncaught DOMException: Failed to execute 'querySelectorAll' on 'Document': '#someID:not(.classNameOne > div, .classNameTwo > div, div[class*="-something"] > div)' is not a valid selector.
at <anonymous>:1:10
If anyone has a better solution to replacing this jQuery function, I would greatly appreciate it!
Thank you!