jQuery html() in Firefox (uses .innerHTML) ignores DOM changes
2010-03-05 00:00
651 查看
DOM:
jQuery plugin that makes .formhtml() automatically do this:
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 html() in Firefox (uses .innerHTML) ignores DOM changes
- jQuery html() in Firefox (uses .innerHTML) ignores DOM changes
- Firefox 不支持 DOM 对象的 outerHTML innerText outerText 属性
- jQuery中的text()、html()和val()以及javascript中的innerText、innerHTML和value
- javascript DOM innerHTML createElement createTextNode
- jQuery中的text()、html()和val()以及innerText、innerHTML和value
- HTML DOM && jQuery setTimeout() && setInterval() 方法
- DOM 操作内容 innerText/innerHTML
- JQuery3.1.1源码解读(十六)【dom-html】
- jQuery 操作DOM总结,DOM Core操作,HTML-DOM操作和CSS-DOM操作
- DOM操作 vs. innerHTML
- 如何让动态创建的页面元素响应用户事件 (HTML/javascript/jQuery/Ajax/DOM)
- HTML DOM innerHTML 属性
- jQuery DOM-获取、设置、添加、删除html文本的内容
- 16、使用jQuery操作DOM之操作HTML、文本和值
- JQuery 操作DOM(HTML)
- Using the innerText Property in Firefox
- jQuery中的text()、html()和val()以及innerText、innerHTML和value
- 【美图】有如下列表的DOM结构,需要在点击li时获取对应的innerHTML
- Dom and innerHTML