jquery: IE7 won't prepand a label to the corresponding inputs div-container
I want to make sure that the structur of my form is like that:
<form>
<div>
<label>
<input>
</div>开发者_运维百科;
<form>
I use jquery to catch the label from whereever it is and move it between <div>
and <input>
.
This works fine in Firefox but IE has problems with that. How can I get it running with IE?
Here's the line that causes errors in IE6 and IE7:
var inputname = $(this).attr('name');
$(this).parents('form').find('label[for='+inputname+']')
.prependTo($(this).parent('div.slidebeyond-div'));
Thank you!
Question: how are you verifying that the element is not being moved?
When you run the code in FF, the label
element gets moved to directly below the div
You can verify this with Firebug.
When you run the code in IE the label also gets moved to the right spot. If you use view source to inspect the DOM you are only seeing the DOM before all of your jQuery did its thing.
Edit I am also assuming that the code you have supplied is within a:
$('input').each(function(){});
精彩评论