JQuery loop through HTML5 Data Attributes - Javascript jQuery

Javascript examples for jQuery:Data Attribute

Description

JQuery loop through HTML5 Data Attributes

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.0.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*from   www  .  j av a2 s  . c o  m*/
$.each($('a').data(), function(i, v) {
    console.log('"' + i + '":"' + v + '",');
});
    });

      </script> 
   </head> 
   <body> 
      <a data-type="file" data-path="/some/path" data-size="123">Link</a>  
   </body>
</html>

Related Tutorials