如果选择了按钮,我基本上是在尝试使用列表类在div中打印按钮的值。取消选择时,还要删除相同的值。我能够成功打印该值,但无法将其删除。有人可以帮我解决这个问题。
var buttonSelect = $(".btn").click(function() {
if ($(this).hasClass('active')){
$(".list").append(this.value + " ")
}
else {
$(".list").remove(this.value)
}
});
您应该将内容与span等html元素一起附加:
$(".btn").click(function() {
if ($(this).hasClass('active')){
$(".list").append('<span class="newval_'+this.value+'">'+this.value + "</span>");
}else{
$(".list").find('.newval_'+this.value).remove();
}});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句