Show element attribute on click event - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:attr

Description

Show element attribute on click event

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <title>  UIDesigner</title> 
 </head> /*  w  w w  .jav a2 s  .  co m*/
 <body translate="no"> 
  <div class="fullkey"> 
   <div data-keyid="c-key">
     Click Here 
   </div> 
  </div> 
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 
  <script>
       $('.fullkey div').click( function (){
        var keyId = $(this).attr('data-keyid');
        console.log(keyId);
    });
    
      </script>  
 </body>
</html>

Related Tutorials