article

Sunday, November 23, 2014

How to Get Element id Using Jquery

How to Get Element id Using Jquery 

 
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
 <head>
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
 <script type="text/javascript"> 
  $(document).ready(function () {
   $('.test').click(function() { 
     alert('' + $(this).attr('id'));
   });
  });  
 </script> 
 </head>
 <body>
  <input type="button" value="Button A" class="test" id="buttonA"> 
  <input type="button" value="Button B" class="test" id="buttonB">
 </body>
</html>

Related Post