jquery issue , experts advice needed, index not updating
I have a few elements in my document, after loading everything I change the positions of some elements using jquery, but the indexes are not updating, As per my knowledge when an element move above another its index should update, is there any command in jquery to update the index after a movement in the document.
thank yo guys
I get the index using indx = $("#container div").index($('#div_'+id));
then I change the position of this element ( to above another element by changing the css top value) after this, If i check the index of this element remains same, actually this element is in top position, 开发者_如何学Pythonso I think it index must change
You need to change the position in the dom, look at appendTo, prependTo, insertBefore, insertAfter. So instead of moving the actual box on your screen you need to move it in the html like this:
<div>
<div id="1"></div>
<div id="2"></div>
<div id="3"></div>
</div>
to
<div>
<div id="1"></div>
<div id="3"></div>
<div id="2"></div>
</div>
Then the index will change
精彩评论