日期:2014-05-16 浏览次数:20307 次
$(document).ready(function () { var a = $("#li1").clone(); $("#li1").remove(); $("#li2").after(a); });
------解决方案--------------------
function exchangePos(elem1, elem2){ if(elem1.length === 0 && elem2.length === 0){ return; } var next = elem2.next(), parent = elem2.parent(); elem1.after(elem2); if(next.length === 0){ parent.append(elem1); }else{ next.before(elem1); } } var ul = $('ul'); exchangePos(ul.children().eq(1), ul.children().eq(3));