Reputation: 11
I could help, I need a code in jQuery to do the following:
A code each time it finds "Texto 0" in any part of the body. When is "Texto 0" replace style1 by style2 (or remove style1 and add style2)
My code is this. The "..." represent other codes in between.
<div span="menu> <span> Texto 0 </ span> </ div>
....
....
...
<span class="style1"> Hello </ span>
Upvotes: 1
Views: 86
Reputation: 2883
$('span').each(function(index) {
if($(this).val().indexOf("Text 0") !== -1) {
$(this).removeClass('style1')
$(this).addClass('style2')
}
})
Upvotes: 0
Reputation: 128781
$('span:contains("Texto 0")').each(function() {
if($(this).hasClass('style1'))
$(this).removeClass('style1').addClass('style2');
});
Upvotes: 1