4
与jQuery,我试图做类似本网站所使用的过滤系统的功能(example)如何删除克隆元素
如果单击过滤元件之一,它会显示在另一个区域。您可以通过单击来删除选定的过滤器。
我的代码工作的克隆滤芯,而在另一个区域中显示,但 我有移除故障。
我做的研究小时,但找不到任何解决方案,使您的帮助将不胜感激!
这里是我的代码
--- HTML ---
<div id="filter-selected>
<ul>
<!--selected element comes here -->
</ul>
</div>
<div id="filter-options">
<ul>
<li>
<!--clicking this list will clone itself to the above area-->
<span>Value1</span>
</li>
<li>
<!--clicking this list will clone itself to the above area-->
<span>Value2</span>
</li>
</ul>
</div>
--- jQuery的---
$('#filter-options > ul > li').click(function(event){
var $filter = $(this).children('span').clone();
$filter.appendTo('#filter-selected > ul').wrap('<li class="filtering"></li>');
});
$(.filtering').click(function(){
$(this).remove();
});
太谢谢你了!有效!! – masanorinyo