Change div tag data attribute - Javascript jQuery

Javascript examples for jQuery:Data Attribute

Description

Change div tag data 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://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.js"></script> 
  <script type="text/javascript">
    window.onload=function(){/*from w  w w.ja  v  a  2  s. c o  m*/
newData = ['hello']
$('div').attr('data-serie-data', newData)
console.log($('div'))
    }

      </script> 
 </head> 
 <body> 
  <div data-serie-data="[4.0,4.0,3.0,4.0,3.0]" id="chartContainer"> 
  </div>  
 </body>
</html>

Related Tutorials