is(expr)
<html> <head> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("div").one('click', function () { if ($(this).is(":first-child")) { $("p").text(":first-child"); } else if ($(this).is(".blue,.red")) { $("p").text("It's a blue or red div."); } else if ($(this).is(":contains('asdf')")) { $("p").text("It's asdf!"); } else { $("p").html("It's nothing <em>special</em>."); } }); }); </script> <style> div.middle { color: red; } </style> </head> <body> <body> <div>asdf</div> <div class="blue">asdf</div> <div class="red">asdf</div> <div><span>asdf</span>asdf</div> <div class="blue">asdf</div> <p>asdf</p> </body> </html>