2016-09-19 20 views
-1

我有一個問題可以歸結爲將'UL'的li傳送到另一個'UL'命令以堵塞先前刪除的孔讀。這是問題的一個例子:JSFIDDLE我該如何攜帶li'sa ul並將其放入另一個ul中

var listaPrateleiras = $(".prateleira.n3colunas > ul > li"); 
if ($(listaPrateleiras).has(".flag").length) { 
    $(listaPrateleiras).not(':has(".flag")').remove(); 
} 

UPDATE:這是什麼OP希望

enter image description here

enter image description here enter image description here

+0

問題還不清楚。 – Satpal

+0

@Satpal基本上,在第二個圖像中,我需要選擇兩個是lis,並將它們放在ul頂部......也就是說,佔據第一個空間ul –

+0

這是你想要的嗎? http://i.imgur.com/05uwoR1.jpg – cjmling

回答

2

請注意,我添加了兩個類upperullowerulul元素,這裏是工作示例https://jsfiddle.net/wnv3moLr/1/

var listaPrateleiras = $(".prateleira.n3colunas > ul > li"); 
if ($(listaPrateleiras).has(".flag").length) { 
    $(listaPrateleiras).not(':has(".flag")').remove(); 

    $(".upperul").append($(".lowerul").html()); //Copy all html left from lowerul to upperul 

    $(".lowerul").html(""); //Now remove all html inside lowerul 
} 
相關問題