jQuery: How can I use “$” instead of “jQuery”?

前端 未结 3 1394
天命终不由人
天命终不由人 2021-02-11 01:43

I have simple jQuery in my site, yet I keep getting this error:

Uncaught TypeError: Property \'$\' of object [object DOMWindow] is not a function
3条回答
  •  没有蜡笔的小新
    2021-02-11 02:11

    You can wrap your code:

    (function($) {
        // here $ would be point to jQuery object
        $(document).ready(function() {
            $('#pass').keyup( ... );
        });
    })(jQuery);
    

提交回复
热议问题