开发者

loading a layout with sortable

开发者 https://www.devze.com 2023-02-16 12:56 出处:网络
Im using jquery sortable and connected lists that works great. I have two lists, and 4 list elements... two in each list.

Im using jquery sortable and connected lists that works great. I have two lists, and 4 list elements... two in each list.

But how do i do it if a var is true and i then开发者_StackOverflow want the page loaded with all 4 elements in one list?

html:

<ul id="list1">
<li id="elem1">elem1</li>
<li id="elem2">elem2</li>
</ul>

<ul id="list2">
<li id="elem3">elem3</li>
<li id="elem4">elem4</li>
</ul>

jquery:

if( true )
{
// place elem 3 and 4 in list 1
}


if(true) {
document.getElementById("list1").innerHTML += document.getElementById("list2").innerHTML;
document.removeChild(document.getElementById("list2"));
}


You can try something like this :

function moveElem(elem) {
    $('#list1').append(elem);
}

if(true) {
    moveElem($('#elem3'));
    moveElem($('#elem4'));
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号