Home
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script> $(document).ready(function () { $("button").click(function () { if ($('#myDiv').is('div')) { $("#myDiv").css("background-color", "yellow"); } }); }); </script> </head> <body> <h1>jQuery DOM Traversing Methods: is()</h1> <div id="myDiv">This is div. </div> <p>This is paragraph. </p> <button>Click Here to Test .is()</button> </body> </html>
Result: