$(".zygw_zan").children().click(function(){
var this_text = $(this).text();
var index = $(this).index();
//判断是否active
if(this.getAttribute("class")=='active'){
$(this).removeClass("active");
}else{
$(this).addClass("active");
var text = $("#zygw_textarea").val();
text += this_text+" ";
$("#zygw_textarea").val(text).css({"color":"#888888"});
}
})
已修改答案.
点击按钮时,判断是否有class
如果有,则使用正则将按钮文字替换为空字符串
如果没有,则加上按钮文字
自己拿去修改吧,我不会写代码,这已经是我极限了