Detect which anchor is clicked - Javascript DOM Event

Javascript examples for DOM Event:onclick

Description

Detect which anchor is clicked

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <a href="javascript:changeFreq(this)">Anchor 1</a> 
      <a href="javascript:changeFreq(this)">Anchor 2</a> 
      <a href="javascript:changeFreq(this)">Anchor 3</a> 
      <script type="text/javascript">
function changeFreq(element) {//from  w  w w  .  j  a  va  2  s .c  o m
    // element is the ... wait for it ... element
    console.log(element);
}

      </script>  
   </body>
</html>

Related Tutorials