Turn data-attribute array into object - Javascript jQuery

Javascript examples for jQuery:Array

Description

Turn data-attribute array into object

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-1.11.0.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*  ww  w. ja v a 2s . co m*/
console.log( $('#test').data('options') )
    });

      </script> 
   </head> 
   <body> 
      <div id="test" data-options="{&quot;multiExpand&quot;:true,&quot;otherOption&quot;:false}"></div>  
   </body>
</html>

Related Tutorials