Javascript examples for jQuery:Json
Javascript parse string as object or JSON
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> <script type="text/javascript"> $(function(){/*from ww w . ja v a 2s.com*/ var mydata = JSON.parse($('#test').attr('mydata')); console.log(mydata.xkey); }); </script> </head> <body> <div id="test" mydata="{"xkey":"xval","ykey":"yval"}"> </div> </body> </html>