I have this code:
<a href="javascript:alert('something1')">Click</a>
<a href="javascript:prompt('something2')">Click</a>
<a href="javascript:alert('something3')">Click</a>
<a href="javascript:prompt('something4')">Click</a>
Now, using console.log(document.querySelectorAll("a[href^='javascript:prompt('],a[href^='javascript:alert(']"));
would fetch all such elements as NodeList.
But, I have the HTML text given with different case of letters in javascript
. That is, look at the following code:
<a href="javaSCRIPT:alert('something1')">Click</a>
<a href="JaVaScRIPt:prompt('something2')">Click</a>
<a href="javaSCRIpt:alert('something3')">Click</a>
<a href="JAVAscrIPt:prompt('something4')">Click</a>
I referred this, but using *=
instead of ^=
doesn't help. I know ^=
equates to 'starts with', but what does *=
mean?
How can I write a generic querySelectorAll
for all such permutations of javascript
?
*=
means that it contains the text, for example in jQuery docs: api.jquery.com/attribute-contains-selector – StentorianquerySelector*
methods respect/use the CSS selectors: developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors – Backstitch