Open page based on id selector - Javascript jQuery

Javascript examples for jQuery:Tag Traversing

Description

Open page based on id selector

Demo Code

ResultView the demo in separate window

<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>

Related Tutorials