Passing parameters in javascript onClick event using Jquery - Javascript jQuery

Javascript examples for jQuery:Mouse Event

Description

Passing parameters in javascript onClick event using Jquery

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript">
    window.onload=function(){// w  w  w  .j a  v  a2  s  . c o  m
$("#click-sample").click(function(e){
   console.log($(e.target).attr('some-data'));
});
    }

      </script> 
 </head> 
 <body> 
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
  <div id="click-sample" some-data="You got data inside Click">
    Click Here 
  </div>  
 </body>
</html>

Related Tutorials