インデックスによって兄弟内の要素の位置を意味する場合、after()、before()、insertAfter()、insertBefore()、append()、appendTo()などの多くのjQueryメソッドを使用して要素を簡単に移動できます簡単な例を次に示します。
HTML:
<div class="invoiceLine">
1 <input />
</div>
<div class="invoiceLine">
2 <input />
</div>
<div class="invoiceLine">
3 <input />
</div>
JS:
$('.invoiceLine').find('input').change(function() {
var line = $(this).closest('.invoiceLine'); // find enclosing invoiceLine
var next = line.next(); // find next invoiceLine
if (next.length) // check that current line is not last
line.insertAfter(next); // insert current line after the next one
});
フィドル: http: //jsfiddle.net/antishok/DteuU/