loading a layout with sortable
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'));
}
精彩评论