javascript - How to get innerHTML including data attributes -
i'm using document.body.innerhtml text version of html can store , reload later using jquery's append. works fine isn't saving data-* attributes i'm storing in html nodes. there method can me string of innerhtml including data attributes?
assuming using jquery .data():
jquery's .data() method storing data in javascript , not html attributes. existing data-* attributes pulled object. more information check docs.
to save data html data attributes use .attr(). following:
$('.el').attr('data-foo', 'bar');
Comments
Post a Comment