How to get form html() via jQuery including updated value attributes?

If you really must have the HTML, you need to actually update the “value” attribute manually:
http://jsfiddle.net/brLgC/4/

$(document).ready(function() 
{
    $('a').on('click', function() {
        $("input,select,textarea").each(function() {
           if($(this).is("[type="checkbox"]") || $(this).is("[type="checkbox"]")) {
             $(this).attr("checked", $(this).attr("checked"));
           }
           else {
              $(this).attr("value", $(this).val()); 
           }
        });
        alert($('form').html());
    });
});

Leave a Comment