Firefox의 jQuery html()(.innerHTML 사용)은 DOM 변경을 무시합니다._jquery

WBOY
풀어 주다: 2016-05-16 18:32:55
원래의
1094명이 탐색했습니다.

DOM:

复代码 代码如下:

function DisplayTextBoxValue(){
var 요소 = document.getElementById('textbox');
// DOM 요소의 속성을 직접 설정 - innerHTML을 업데이트합니다.
element.setAttribute('value', element.value);
alert(document.getElementById("container").innerHTML);
거짓을 반환합니다.
}

.formhtml()을 자동으로 수행하는 jQuery 플러그인:
复system代码 代码如下:

(function($) {
var oldHTML = $.fn.html;
$.fn.formhtml = function() {
if (인수 .length) return oldHTML.apply(this,arguments);
$("input,textarea,button", this).each(function() {
this.setAttribute('value',this.value) ;
});
$(":radio,:checkbox", this).each(function() {
// "checked"를 위해 이 작업을 수행해야 하는지 잘 모르겠습니다
// 그런데 뭐, 후회하는 것보다는 안전해요
if (this.checked) this.setAttribute('checked', 'checked')
else this.removeAttribute('checked'); });
$("option", this).each(function() {
// 확실하지 않지만 더 안전합니다...
if (this.selected) this.setAttribute( '선택됨');
else this.removeAttribute('selected');
})
return oldHTML.apply(this)
//선택 사항 원하는 경우 실제 .html()을 재정의하려면
// $.fn.html = $.fn.formhtml
})(jQuery);

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!