在學習鏈式運動的時候遇到了一個問題,在此記錄下來。
由於鏈式運動是有一個回調函數
singleAttrMove(this,'width',400,function(){
singleAttrMove(this,'height',300);
});
經過測試,如果回調函數裏面的Element參數傳this的話會報錯,因此,需要先定義一個that來保存this
var that = this;
然後再調用即可
var that = this;
singleAttrMove(this,'width',400,function(){
singleAttrMove(that,'height',300);
});