Reputation: 81
Hi I have this piece of code and what I want to happen is to, find all div "Complete!" then if it exist apply the css but only on "this" that was found and not the other ones that have a similar class, here's my code
var boxComplete = $('.profile-block p').text().indexOf('Complete!') > -1;
if (boxComplete) {
$('.profile-block p').parent().css('background', 'rgba(255,255,255,0.2)');
}
The issue here is that it's applying the css to all other parent divs and I only want it on the one that was found
Upvotes: 0
Views: 35
Reputation: 171669
Can use :contains
selector.
$('.profile-block p:contains(Complete)').parent().css('background','rgba(255,255,255,0.2)');
Upvotes: 0