Set event function trigger in looping with jquery - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:click

Description

Set event function trigger in looping with 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" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
 </head> //from  w ww .j a  va2 s .  c om
 <body> 
  <button class="someclass" data-value="1">click 1</button> 
  <button class="someclass" data-value="2">click 2</button> 
  <script type="text/javascript">
  $('.someclass').click(function(){
     console.log($(this).attr('data-value'));
  });

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

Related Tutorials