javascript 在外部文件中创建jquery函数

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 在外部文件中创建jquery函数相关的知识,希望对你有一定的参考价值。

// create a namespace (an object in the global scope) and attach your function to that
(function () {

    // Initialize namespace 'utilities' (or use existing one if present)
    window.utilities = window.utilities || {};

    // Add function 'myFunction' to the namespace
    utilities.myFunction = function () { ... };

})();



// use the function in a script later like this
var something = utilities.myFunction();

以上是关于javascript 在外部文件中创建jquery函数的主要内容,如果未能解决你的问题,请参考以下文章