Side navigation
#1866 closed bug (duplicate)
Opened October 31, 2007 06:57AM UTC
Closed November 27, 2007 07:53PM UTC
IE6, appech checkbox to div, checked attribute gone.
| Reported by: | zozoh | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.2.2 |
| Component: | core | Version: | 1.2.1 |
| Keywords: | IE6 append checkbox | Cc: | |
| Blocked by: | Blocking: |
Description
Example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var c = $("<INPUT type=checkbox>");
c[0].checked = true;
$("#before").text(c[0].outerHTML);
$("#cc").append(c);
$("#after").text(c[0].outerHTML);
});
</script>
</head>
<body>
<div id="cc"></div>
<b>Before:</b>
<div id="before"></div>
<b>After:</b>
<div id="after"></div>
</body>
</html>
Execute result:
Before: <INPUT type=checkbox CHECKED> After: <INPUT type=checkbox>
I try to update append code like this:
append: function() {
return this.domManip(arguments, true, 1, function(a){
if(jQuery.browser.msie && jQuery.nodeName(a, "input") && a.type.toLowerCase()=="checkbox"){
var checked = a.checked;
this.appendChild( a );
a.checked = checked;
}else
this.appendChild( a );
});
}
it worked.
Attachments (0)
Change History (3)
Changed October 31, 2007 10:09AM UTC by comment:1
Changed November 07, 2007 03:28AM UTC by comment:2
Duplicate of http://dev.jquery.com/ticket/769
function "append":
append: function() { return this.domManip(arguments, true, 1, function(a){ /* Special for IE */ if(a && a.nodeType==1 && jQuery.browser.msie && jQuery.browser.version=="6.0"){ /* store original */ var arr = new Array(); jQuery(a).find(":checkbox").andSelf().filter(":checkbox").each(function(){ arr.push(this.checked); }); this.appendChild( a ); /* restore */ if(arr.length>0){ var jq = jQuery(a).find(":checkbox").andSelf().filter(":checkbox"); for(var i in arr) jq[i].checked = arr[i]; } }else{ this.appendChild( a ); } }); },It work in most of cases.