I have something like this HTML code:
<ul>
<li><a href="#">21</a></li>
<li><a href="#">10</a></li>
<li><a href="#">6</a></li>
<li><a href="#">1</a></li>
<li><a href="#">7</a></li>
<li><a href="#">5</a></li>
</ul>
And I want to make a Jquery code that add class to the link with the gave text (notice that have to be exactly the text).
For example, if I call Method(1, "replaced text") then this has to be the HTML result:
<ul>
<li><a href="#">21</a></li>
<li><a href="#">10</a></li>
<li><a href="#">6</a></li>
<li><a class="myclass" href="#">1</a>replaced text</li>
<li><a href="#">7</a></li>
<li><a href="#">5</a></li>
</ul>
You can use filter() to match the element, then chain addClass() into after():