下面是html部分
<li class="main_menu catagory_li" id="cat4">
<p class="ahead"><span class="heading">Item 4</span>
<span class="fright remove">close</span></p>
</li>
当我点击close
我复制LI
使用下面的代码,
$('.remove').live('click',function(){
var closed_elem_id = $(this).parent().parent().attr('id');
s = $(this).parent().parent().clone().wrap('<div>').parent().html();
$('li#'+closed_elem_id).remove();
console.log(s);
});
此删除LI
特定位置并获取副本并将其存储在variable s
.
我的要求是在克隆副本中添加名为 no-display 的类,例如<span class="fright remove no-display">close</span>
. 我尝试了很多方法,但都失败了。
请就此提出建议
注意:更新了我的问题