store and retrieve javascript arrays into and from HTML5 data attributes
It turned out that you could use the html escaped characters in the element data attribute to have json-like array (encoded are quotes): <div id=”demo” data-stuff=”["some", "string", "here"]”></div> And then in javascript get it without any additional magic: var ar = $(‘#demo’).data(‘stuff’); Check this fiddle out. Edited (2017) You don’t need to use html escaped … Read more