@require-ing jQuery overwrites the page's $ variable

前端 未结 2 1716
夕颜
夕颜 2020-12-19 18:52

I\'m @require-ing jQuery for my Greasemonkey script with this line in my script file:

// @require https://ajax.googleapis.com/ajax/libs/jquery/1         


        
2条回答
  •  星月不相逢
    2020-12-19 19:46

    See jQuery.noConflict();; it explains a lot.

    EDIT:
    Found "Greasemonkey 1.0 + jQuery: Broken, with Workaround" on searching.

    Possible solution:

     this.$ = this.jQuery = jQuery.noConflict(true);
    

    Doing that, probably will implicitly specify that $, jQuery will be available in your script's namespace.

提交回复
热议问题