get ID of 'this' variable - Javascript jQuery Selector

Javascript examples for jQuery Selector:id

Description

get ID of 'this' variable

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-2.0.2.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//from  w w  w .  j  a va2  s  .  co m
$('.my').keyup(function(event) {
   console.log($(this).attr("id"));
});
    });

      </script> 
 </head> 
 <body> 
  <input type="text" id="i1" class="my"> 
  <input type="text" id="i2" class="my"> 
  <input type="text" id="i3" class="my">  
 </body>
</html>

Related Tutorials