JavaScript/jQuery - “$ is not defined- $function()” error

后端 未结 8 2028
轻奢々
轻奢々 2020-11-30 08:15

I am trying to run a JavaScript/jQuery function and Firebug gets the error:

$ is not defined $(function()\".

The JavaScript code is placed

8条回答
  •  一向
    一向 (楼主)
    2020-11-30 08:55

    Try:

    (function($) {
        $(function() {
            $('.update').live('change', function() {
                formObject.run($(this));
            });
        });
    })(jQuery);
    

    By using this way you ensure the global variable jQuery will be bound to the "$" inside the closure. Just make sure jQuery is properly loaded into the page by inserting:

    
    

    Replace "http://code.jquery.com/jquery-1.7.1.min.js" to the path where your jQuery source is located within the page context.

提交回复
热议问题