我使用下面的ocde所以我可以使用$ short手来获取jQuery:
jQuery(function($){ ... }
Run Code Online (Sandbox Code Playgroud)
但我也有一些需要jQuery的功能.我怎样才能在这些功能中使用$ short手?似乎$在我的函数中不起作用.
如果页面上有另一个用作对象的脚本$,function则不能在其外部使用$.但是,您可以使用noConflict创建别名$或jQuery.
(function($) {
// Use $ here
})(jQuery);
// Create an alias of jQuery
var $_ = jQuery.noConflict();
// Use $_ here
Run Code Online (Sandbox Code Playgroud)