Jquery 我需要删去“;李",;谁拥有与attr输入相同的类
这是我的jquery代码 取消选中复选框时删除li 有人能帮我吗Jquery 我需要删去“;李",;谁拥有与attr输入相同的类,jquery,Jquery,这是我的jquery代码 取消选中复选框时删除li 有人能帮我吗 $('.field').on({ 'click': function() { var price = $(this).val(); text = $(this).next().html(); name = $(this).attr("name"); if($(this).is(':checked'))
$('.field').on({
'click': function() {
var price = $(this).val();
text = $(this).next().html();
name = $(this).attr("name");
if($(this).is(':checked')) {
$('.content-car ul').append('<li class='+ name + '><span class="titre">'+ text +'</span><span class="prix">'+ price + '</span></li>');
} else {
//
}
}
});
$('.field')。在({
“单击”:函数(){
var price=$(this.val();
text=$(this.next().html();
name=$(this.attr(“name”);
如果($(this).is(':checked'){
$('.content-car-ul').append(''+text+'+price+'');
}否则{
//
}
}
});
您可以使用$('.content car ul li.'+name).remove()
删除li
在下面试试
$('.field')。在({
“单击”:函数(){
var price=$(this.val();
text=$(this.next().html();
name=$(this.attr(“name”);
如果($(this).is(':checked')){
$('.content-car-ul').append(''+text+'+price+'');
}否则{
$('.content car ul li.'+name).remove();
}
}
});代码>
- ---
1.
2.
.content car ul
元素中是否有多个li元素?thx但我仍然有相同的问题…仍然有相同的问题-什么问题?复选框未选中且li项仍然存在!!