Reputation: 5487
I have a value coming in from a CMS which I don't have access to and am looking for a jquery workaround. I'd like to target an anchor link based on value and then replace. I know how to do this based on class or ID but I don't have access to edit those.
Here is my rendered html:
<a class="searchtitle" href="https://sitname.com">STRONG</a>
Would it be possible to target $(.searchtitle) where the value equals strong and replace it with a new value?
Upvotes: 1
Views: 52
Reputation: 9356
Another option is to use filter() Here's a demo
$('.searchtitle').filter(function(){
return $(this).text() == "STRONG";
}).text('hello');
Upvotes: 2
Reputation: 7207
Try this:
$('.searchtitle').filter(function(){
return $(this).html()=="STRONG";
}).html("new value");
Upvotes: 0