我的 HTML:
<div id="my-slider">
<img src="/slider/pic/bf3.jpg" alt="picture">
<img src="/slider/pic/bf3_cq.jpg" alt="picture">
<!-- etc -->
</div>
在特定事件中,我想将最后一个 img 标签移动到第一个位置(根据父级)
我尝试:
curr.css('left', 0);
curr.prepend(curr.parent());
我可以更改 css,但第二行引发错误:
HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy
有人可以给我任何建议吗?
最佳答案
curr.parent().prepend(curr);
或
curr.prependTo(curr.parent());
关于jquery - 将最后一个子元素移动到第一个位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11700995/