不能用this?
$(document).ready(function(){
??????
??????this.click(function(){
??????????$(".car").animate({
??????????????top:500
??????????},{
??????????????duration:600
??????????})
??????})
??????
??????
});為什么不能用this而非得用$(".car")進行操作呢?
2017-07-02
舉報
2017-07-06
你這里的this指的是document根節點。
如果你想要的效果是點擊該文檔頁面中任意位置都能觸發該動畫事件的話,
應該是用 ? this.onclick=function(){ ? ?//事件 ? ? ? ?} ? ? ?- ?this ?JS對象
或者 ?this.click(function ... ? ? 改成 ?$(this).click(function ... ? ? ?- $(this) ?JQ對象
2017-07-06
知道啦