Answers for "store json object in data attribute in html"

0

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>
Posted by: Guest on October-06-2021

Code answers related to "store json object in data attribute in html"

Browse Popular Code Answers by Language