Re: [問題] 如何取得父層函式的this

看板Ajax作者 ( ◤〔ζ狼ζ〕◢)時間14年前 (2011/07/14 23:04), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串3/5 (看更多)
你要這種嗎XD $('#tt tr').click(function(){ var self = this; function(){ self.xxxx; // 父層的this this.hide() } }); 如果第二個function 是包callback 他的this才會不一樣不是嗎@__@ ※ 引述《genomini (不重要)》之銘言: : 假如 : $('#tt tr').click(function(){ <--父層 : function(){ : this.hide() <---這邊的this : } : }); : 請問有無指令是可以取得父層的this呢? : 還是說只能在外面多加一個變數存父層的this : 然後再子層呼叫那變數@@ : 如 : $('#tt tr').click(function(){ <--父層 : var x = $(this); : function(){ : x.hide() <---這邊的this : } : }); -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.42.3.194

07/16 10:55, , 1F
恩 了解了 感謝喔
07/16 10:55, 1F
文章代碼(AID): #1E7mLzJe (Ajax)
文章代碼(AID): #1E7mLzJe (Ajax)