Question

This is a rather specific question but I am trying to use querySelectorAll for all 'a' tags that have a 'href' value that is a specific length AND does not contain 'html' at the end of that value.

I understand the basics of querySelectorAll but not how to accomplish something like this...

Thank you for any help offered.

Was it helpful?

Solution

Currently, it's not possible to impose any sort of length restriction on attribute values using selectors.

The closest you can get is this, without the length restriction:

document.querySelectorAll('a[href]:not([href$="html"])');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top