开发者

How can i call a JQuery function outside of a JQuery class?

开发者 https://www.devze.com 2022-12-13 12:03 出处:网络
I have开发者_开发知识库 a class: var BrandDrug = Class.extend({ fun1: function() { $.MyFunc(); //This does not work.

I have开发者_开发知识库 a class:

var BrandDrug = Class.extend({
    fun1: function() {
       $.MyFunc(); //This does not work.
    }
});


//Outside function
$.MyFunc = (function() {
   //Code
});

How can i call the $.MyFunc from the BrandDrug Class?


You have to define the "$.MyFunc" before the "BrandDrug" class and it will work.

edit: also note that you are not extending jQuery properly. See this tutorial (for example) on how to build proper jQuery plugins.

0

精彩评论

暂无评论...
验证码 换一张
取 消