Question

Here the point with a exemple :

<h2>        
  <a href="/car/bmw/?load=0&value=5fs4dfsdf45"> </a>
</h2>

I want my querySelector to only select "bmw".

I used it (below), but it's only select the end of the sentence and not the value between "/car/" and "?load"

document.querySelector('h2 > a[href$=]');

Thanks for your help !

Was it helpful?

Solution

try *= instead:

document.querySelector('h2>a[href*=bmw]')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top