I have a form with a textbox like this:
$('[type=text], textarea').each(function(){ this.defaultValue = this.value; });
$('[type=checkbox], [type=radio]').each(function(){ this.defaultChecked = this.checked; });
$('select option').each(function(){ this.defaultSelected = this.selected; });
then
$("body").html()
Well there is one most simpler way of doing this, by employing the live function on the input.
$(document).ready(function() {
var checker = false;
$("input").live("change", function() {
checker = (this.defaultValue !== this.value);
if (checker)
this.defaultValue = this.value;
});
});
$('input').each(function(){
$(this).attr('data-value-input', $(this).val());
});
and after that you can get your html
var bodyHtml = $('body').html().toString().replace('data-value-input', 'value');
and that is it.
You can use the .attr()
function.
Example:
$("input").each(function(){
$(this).attr("value", $(this).val());
});
After this you can do the:
$("body").html();
This should work.