jQuery html() in Firefox (uses .innerHTML) ignores DOM changes
function DisplayTextBoxValue(){
var element = document.getElementById('textbox');
// set the attribute on the DOM Element by hand - will update the innerHTML
element.setAttribute('value', element.value);
alert(document.getElementById("container").innerHTML);
return false;
}
jQuery plugin that makes .formhtml() automatically do this:
(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() {
// im not really even sure you need to do this for "checked"
// but what the heck, better safe than sorry
if (this.checked) this.setAttribute('checked', 'checked');
else this.removeAttribute('checked');
});
$("option", this).each(function() {
// also not sure, but, better safe...
if (this.selected) this.setAttribute('selected', 'selected');
else this.removeAttribute('selected');
});
return oldHTML.apply(this);
};
//optional to override real .html() if you want
// $.fn.html = $.fn.formhtml;
})(jQuery);
- jquery append()方法與html()方法的區(qū)別及使用介紹
- jquery text(),val(),html()方法區(qū)別總結(jié)
- 『jQuery』.html(),.text()和.val()的概述及使用
- innerHTML與jquery里的html()區(qū)別介紹
- JQuery中html()方法使用不當(dāng)帶來(lái)的陷阱
- jQuery獲取文本節(jié)點(diǎn)之 text()/val()/html() 方法區(qū)別
- jquery 學(xué)習(xí)之二 屬性(html()與html(val))
- jquery 的 $("#id").html() 無(wú)內(nèi)容的解決方法
- jQuery html()等方法介紹
- jQuery html()方法使用不了無(wú)法顯示內(nèi)容的問題
相關(guān)文章
jquery檢測(cè)input checked 控件是否被選中的方法
這篇文章主要介紹了jquery檢測(cè)input checked 控件是否被選中的方法,需要的朋友可以參考下2014-03-03jQuery簡(jiǎn)單實(shí)現(xiàn)彩色云標(biāo)簽效果示例
這篇文章主要介紹了jQuery簡(jiǎn)單實(shí)現(xiàn)彩色云標(biāo)簽效果,結(jié)合實(shí)例形式分析了jQuery隨機(jī)數(shù)運(yùn)算與頁(yè)面元素樣式動(dòng)態(tài)操作相關(guān)技巧,需要的朋友可以參考下2016-08-08jQuery實(shí)現(xiàn)簡(jiǎn)單飛機(jī)大戰(zhàn)
這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)簡(jiǎn)單飛機(jī)大戰(zhàn),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-07-07用戶管理的設(shè)計(jì)_jquery的ajax實(shí)現(xiàn)二級(jí)聯(lián)動(dòng)效果
下面小編就為大家?guī)?lái)一篇用戶管理的設(shè)計(jì)_jquery的ajax實(shí)現(xiàn)二級(jí)聯(lián)動(dòng)效果。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧2017-07-07jQuery.validate.js表單驗(yàn)證插件的使用代碼詳解
Validate是基于jQuery的一款輕量級(jí)驗(yàn)證插件,內(nèi)置豐富的驗(yàn)證規(guī)則,這篇文章主要介紹了jQuery.validate.js表單驗(yàn)證插件的使用代碼詳解,需要的朋友可以參考下2018-10-10使用jquery Ajax實(shí)現(xiàn)上傳附件功能
這篇文章主要為大家詳細(xì)介紹了使用jquery Ajax實(shí)現(xiàn)上傳附件功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-10-10jQuery實(shí)現(xiàn)輸入框的放大和縮小功能示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)輸入框的放大和縮小功能,涉及jQuery基于事件響應(yīng)的頁(yè)面元素屬性動(dòng)態(tài)變換相關(guān)操作技巧,需要的朋友可以參考下2018-07-07jQuery序列化form表單數(shù)據(jù)為JSON對(duì)象的實(shí)現(xiàn)方法
這篇文章主要介紹了jQuery序列化form表單數(shù)據(jù)為JSON對(duì)象的實(shí)現(xiàn)方法,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-09-09