将这个js(jquery-getHtml-value.js)文件引入到你的页面中,将$("#ImageButton1").html()替换成$("#ImageButton1").formhtml (),具体代码:如下
(function($) {
var oldHTML = $.fn.html;
$.fn.formhtml =function() {
if (arguments.length) return oldHTML.apply(this,arguments);
$("input,textarea,button", this).each(function() {
this.setAttribute('value',this.value);
});
$(":radio,:checkbox", this).each(function() {
if (this.checked) this.setAttribute('checked', 'checked');
else this.removeAttribute('checked');
});
$("option", this).each(function() {
if (this.selected) this.setAttribute('selected', 'selected');
else this.removeAttribute('selected');
});
return oldHTML.apply(this);
};
})(jQuery);
发布于2017.12.17