-1

I have a page using prototype (don't have much control over that).

What I'd like to do is have a document ready function that only uses "jQuery" once, and then inside that function I can just use $ and it won't conflict with prototype.

This is what I have so far

jQuery(function() {
    var superProperties = $.cookie('mp_' + token + '_mixpanel');
    console.log($.cookie());
});
4

1 回答 1

3

If you want it to run on document load

jQuery(function($) {
    var superProperties = $.cookie('mp_' + token + '_mixpanel');
    console.log($.cookie());
});

If you want it to run immediately

(function($) {
    var superProperties = $.cookie('mp_' + token + '_mixpanel');
    console.log($.cookie());
})(jQuery);
于 2013-07-02T02:35:20.147 回答