开发者

How to create a global shortcut while using JQuery noconflict

How to declare a global window object while using jQuery.noConflict().

I am using following way to avoid Jquery conflict with Mootools

 var $j = jQuery.noConflict();

Now I would like to create global shortcut in jquery and tried as

 window.cc = function() {// code}

But fails and return er开发者_StackOverflow社区ror as cc not deined.


Instead of creating explicit no conflict object we can use jQuery in place of $ or your no conflict object name.


Closures?

jQuery.noConflict();

(function($){
    //code goes here
    // here $ is now jQuery
})(jQuery);

// here $ is not jQuery

and in any of these you can use $ to refer to the jQuery object.

note: I'd also make sure jQuery loads up after any other framework for .noConflict() to work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜