Javascript examples for jQuery:Tag Traversing
Open page based on id selector
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.8.3.js"></script> <script type="text/javascript"> $(window).load(function(){//from w w w. jav a2s .c om $('#a').on('click',function(e){ var clickedElement= e.srcElement; if($(clickedElement).attr("id") == "a"){ console.log("a") } }); }); </script> </head> <body> <div id="a"> asdf </div> </body> </html>