I have the following markup.
<h6>Brand</h6>
<ul>
<li>Orange</li>
<li>Black</li>
<li>Green</li>
</ul>
<h6>Colour</h6>
<ul>
<li>Green</li>
<li>Blue</li>
<li>Black</li>
<li>Orange</li>
</ul>
I am unable to change or physically add into this markup, so hence trying to manipulate with jQuery.
What I want to achieve from this is to be able to change the word Black
to Purple
. But only the word Black
that appears after the H6
containing "Colour"
I have this so far:
$("h6:contains('Colour'):.jqueryCheck:contains('Black')").html("Purple");
This however does not work... Why not?
$("h6:contains('Colour')").next('ul').children("li:contains('Black')").html("Purple");
Or all as one selector string:
$("h6:contains('Colour') + ul li:contains('Black')").html("Purple");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With