Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

store json object in data attribute in html

<!-- When passing objects to an attribute - 
<!-- use single quotes (') rather than double (")
<!-- If passing JSON objects to an attribute - the json has to be valid ie. 
<!-- using " for property and values
<!-- Using double quotes escapes the object when being parsed by JQuery 
<!-- causing it to not be pulled -->
<div data-foobar='{"foo":"bar"}'></div>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #store #json #object #data #attribute #html
ADD COMMENT
Topic
Name
9+9 =