Get and set data-value attribute - Javascript jQuery

Javascript examples for jQuery:Data Attribute

Description

Get and set data-value attribute

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.1.3.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*  ww w .  j  a  va2  s.  co m*/
$(document).ready(function(e) {
    var a = $('#abc').data('value');
    console.log(a);
});
    });

      </script> 
 </head> 
 <body> 
  <a href="javascript:void(0)" id="abc" data-value="funny">Funny</a>  
 </body>
</html>

Related Tutorials