Im trying to make a chrome extension that manipulates a website to press a link if the headline is equal to a variable like:
var wantedItem = "exempel 4";
if ($("h1") == wantedItem) {
$("a")[0].click();
} else {
*tries the next one*
}
But the problem is that the website i try to do this on doesn't name the diffrent h1 and it look like this:
<h1><a class="name-link" href="">exempel 1</a></h1>
<h1><a class="name-link" href="">exempel 2</a></h1>
<h1><a class="name-link" href="">exempel 3</a></h1>
<h1><a class="name-link" href="">exempel 4</a></h1>
<h1><a class="name-link" href="">exempel 5</a></h1>
<h1><a class="name-link" href="">exempel 6</a></h1>
<h1><a class="name-link" href="">exempel 7</a></h1>
<h1><a class="name-link" href="">exempel 8</a></h1>
<h1><a class="name-link" href="">exempel 9</a></h1>
How can i check if my variable is equal to the h1 when there are more with the same name?
Hope anyone can help and understood what i wrote