Using JQuery to find text in an element then perform function

Haq nawaz

New Member
I am trying to at the moment simply alert if an element contains specific text string. Here is what I have so far -\[code\]<div class="first">This is the first div</div><div class="second">This is the second div</div>if($(".first:contains('first')")){ alert("Found It!");}\[/code\]My problem is, it will alert the message regardless, I f I change it to a String that is not in any of the elements it will still output the alert.Can anyone see where I am going wrong?Thanks
 
Back
Top