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

Popular posts from this blog

ruby on rails - ActiveRecord order not working -

javascript - How do you prevent nested queries/catches in sequelize? -

java - ConcurrentModificationException upon committing transaction with Hibernate -