【发布时间】:2017-11-02 01:48:37
【问题描述】:
我正在尝试使用 setTimeout() 方法来使用 jQuery 更改一些 CSS 属性,但我的方法不起作用。当函数应该被执行时,我不断收到“脚本错误”。代码编辑器不是为 jQuery 量身定制的,所以这可能就是我要得到的全部内容。我已将原因缩小到具体的 setTimeout 关键字,其中的代码块不会导致错误。我环顾四周,似乎没有其他人有我目前的问题。那怎么了?
else{//cards do NOT match
$(this).css("backgroundColor", "#ff6666");
$(cardId).css("backgroundColor", "#ff6666");
setTimeout(function(){
$(cardId).children().hide();
$(cardId).css("backgroundColor", "white");
$(this).children().hide();
$(this).css("backgroundColor", "white");
}, 1500);
}
【问题讨论】:
-
console.log(this)
标签: javascript jquery html css settimeout