如何從同一個對象內部調用jQuery插件的功能。我使用確切的建議解決方案http://docs.jquery.com/Plugins/Authoring#Plugin_Methods。從外部的代碼,我可以調用這個方法:從功能的jQuery插件調用功能
$('div').tooltip("myMethod", an_attr);
但我怎麼能調用同一個從內尤其是形成該事件時,「這」不是插件的對象。
var methods = {
var $this = $(this);
init : function(options) {
$this.click(function(){
$this.fn2("myMethod", an_attr); //is it right way?
});
},
fn2 : function() {
//but how can I call the myMethod. here ?
},
myMethod : function() {...
你不需要在'$()'中包裝'this',它已經是一個jQuery對象。 –
你能否詳細說明'this'應該是什麼以及你想調用什麼,按什麼順序? – pimvdb