I have a few elements with the same class name data for example, they could look like this:
<p class="data">AAA</p>
<p class="data">BBB</p>
<p class="data">CCC</p>
<p class="data">DDD</p>
Now I want to loop through all the elements with class name data and see if any of them match a string, say AAA. If it does, then make that element red color.
$(".data").each(function() {
if (this.val() == "AAA") {
$(this).css("color", "red");
}
});
However, this isn't working. Any ideas?