var play = function(){
var counter = 0;
if(counter == 0){
$(this).click(function(e) {
var targetBox = (e.target.id);
$("#" + targetBox).append("something");
counter++;
})
} else if (counter == 1){
$(this).click(function(e) {
var targetBox = (e.target.id);
$("#" + targetBox).append("O");
counter--;
});
}
}
我试图让一个按钮,用一个计数器改变什么附加到我的targetBox
。如果计数器是1,则附加一些东西,如果计数器是0,则附加其他东西。任何帮助将不胜感激有没有办法将不同的东西添加到div与计数器?
感谢这个工作 –