gpt4 book ai didi

jquery - 如何在其内部调用 jQuery 插件的方法?

转载 作者:行者123 更新时间:2023-12-01 01:38:10 24 4
gpt4 key购买 nike

像这样的 jQuery 插件:

var methods = {
init: function(options) {
$("#something").click(function() {
//call method show
});
},
show: function() {
//show something around here.
}
}

..

如何在方法init内调用方法show

最佳答案

您可以使用proxy() ,就像 bind()只是在不支持的地方不需要垫片......

$("#something").click($.proxy(function() {
// `this` is the same as `this` outside the function now.
this.show();
}, this));

关于jquery - 如何在其内部调用 jQuery 插件的方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7749972/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com