我正在尝试使用类stamp2移动元素,因此它位于第五个子元素之后。这就是我的尝试。该项似乎已删除。
$('.stamp2').remove().after('.section:nth-child(5)');
HTML:
<section class="photo small stamp stamp1">..</section>
<section class="photo small stamp stamp2">..</section>
<section class="photo small">..</section>
<section class="photo small">..</section>
<section class="photo small">..</section>
<section class="photo small">..</section>
<section class="photo small">..</section>
<section class="photo small">..</section>
<section class="photo small">..</section>
<section class="photo small">..</section>
<section class="photo small">..</section>
<section class="photo small">..</section>
<section class="photo small">..</section>
<section class="photo small">..</section>
答案 0 :(得分:5)
答案 1 :(得分:1)
$('.stamp2').detach().insertAfter('.section:nth-child(5)')
答案 2 :(得分:1)
您无需将其删除。只需使用after函数就可以了。
$('.stamp2').after($('.section:nth-child(5)'));
答案 3 :(得分:0)
使用Detach()代替Remove(),然后使用InsertAfter()