繁体   English   中英

转移已删除 <li> 物品变成另一个 <ul> 清单

[英]Transfer removed <li> items into another <ul> list

数组“ myPicks”具有一个唯一的类列表(.scifi,.adventure等),这些类将用于排序。

还有一个包含li项的无序列表,所有项都带有“ .possibleMatch”类

我正在使用变量'camel'通过以下方式过滤所有这些'.possibleMatch'li:

var camel = $('.possibleMatch').not(myPicks.join(','));

现在,一旦我叫骆驼,

 camel.html(camel).html();

HTML将更新为一个无序列表,其中只有li项具有“ myPicks”中指定的类。

这可以按我希望的那样工作,但是现在我仍然停留在如何将所有已删除的 li项目移到另一个未排序列表中的问题上,该列表位于原始未排序列表的下面。

我试过了

var noLonger = $('.possibleGames').filter(myPicks.join(','));
$('#somewhatMatch').html(noLonger.html(noLonger).html());

为了尝试将已删除的项目移动到新的无序列表#somewhatMatch,但无济于事,现在原始列表将仅显示li项目, 但没有在“ myPicks”中指定的类。

请帮忙!

-

如果将来有人使用这个晦涩的问题,则代码会起作用:

//not sure why, but must clone beforehand
var llama = camel.clone();
//the following updates the original ul with items that match criteria
camel.html(camel).html();
//the following moves unmatched items into a new ul
$('#somewhatMatch').append(llama);

我想你需要的是

var noLonger = $('.possibleGames').filter(myPicks.join(','));
$('#somewhatMatch').empty().append(noLonger.clone());

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM