Todd Menier schrieb:
> Hello,
> The following test code moves 2 form elements from one location in the 
> DOM to another. Both elements retain their state just fine in FireFox, 
> but in IE the current state of the checkbox is lost when the element is 
> moved:
> 
> <script>
> $(function() {
>     $('#btn').toggle(
>         function() {$('#d1 input').appendTo('#d2');},
>         function() {$('#d2 input').appendTo('#d1');}
>     );
> });
> </script>
> 
> <button id="btn">move</button>
> <div id="d1">1:<input type="checkbox"/><input type="text"/></div>
> <div id="d2">2:</div>
> 
> Is there a "preferred" way to deal with this in jQuery? I can think of a 
> number of ways to deal with it, but I would imagine this is a very 
> common scenario, so I thought I'd ping the group before proceeding with 
> my hack. :-)
> 

Not sure, but I think it's nearly impossible to be handled by jQuery 
without much overhead, so this should be regarded as an IE bug to work 
around...:

$(function() {
     $('#btn').toggle(
         function() {
             var jqInput = $('#d1 input');
             var checked = jqInput[0].checked;
             jqInput.appendTo('#d2')[0].checked = checked;
         },
         function() {
             ...
         }
     );
});


-- Klaus

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to