I think this is what you are looking for: JSFiddle link
In this example, the "magic" innerHTML of the form is notified with all changed attributes and their values. I used jquery getAttributes plugin . Here is the code different from the plugin code:
function magicHTMLloop($el, s, notfirst){ if (notfirst) { s += '<' + $el.get(0).tagName.toLowerCase(); var attrs = $.getAttributes($el); for (var i in attrs){ s += ' ' + i + '="' + $el.attr(i) + '"'; } s += '>'; } $el.children().each(function(){ s += magicHTMLloop($(this), '', true); }); if ($el.children().length && notfirst){ s += '</' + $el.get(0).tagName + '>'; } return s; } function magicHTML($el) { return magicHTMLloop($el, '', false); }
This has a few possible cases of edges that you might want to consider, for example, quotation marks within values ββ(which will result in invalid HTML), but I'm sure you can just avoid it yourself if necessary in your case. As you can see, the result of the magicHTML function is an updated innerHTML:
<input type="text" name="x" value="this is the changed value">
source share