Reputation: 29
I have an html below:
<td class="status">
<span class="fa fa-times-circle" aria-hidden="true"></span>
1
</td>
I want to change the span class to "fa-sun-o" if the class "status" text is 0. The code that I have below doesn't work for some reasons. Can anyone help?
<script>
if $(".status:contains('1')") {
$('.status').nextAll('span:first').removeClass('fa-times-circle').addClass('fa-sun-o');
}
</script>
Upvotes: 0
Views: 267
Reputation: 9583
You don't need an if statement for this. You can just do:
$('.status:contains("1") span').removeClass('fa-times-circle').addClass('fa-sun-o');
Upvotes: 1