Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未捕获的语法错误:意外标记:(jquery)_Javascript_Jquery - Fatal编程技术网

Javascript 未捕获的语法错误:意外标记:(jquery)

Javascript 未捕获的语法错误:意外标记:(jquery),javascript,jquery,Javascript,Jquery,错误出现在函数前面的单词init:之后。我对编码比较新,不确定问题出在哪里。这是jquery init: function (options) { var self = this, o = this.options, c = o.classes, d = $(document), i; // Set up the cart configuration. $.extend(true, o, options); // Set up th

错误出现在函数前面的单词init:之后。我对编码比较新,不确定问题出在哪里。这是jquery

init: function (options) {
        var self = this, o = this.options, c = o.classes, d = $(document), i;
        // Set up the cart configuration.
        $.extend(true, o, options);
        // Set up the storage method.
        this.saveCart = this.setStorageMethod(o.storage);
        if (this.saveCart) {
            this.webstore();
            // Get the shopping cart.
            o.properties = $.merge([ c.id, c.stock, c.price, c.quantity, o.title ], o.properties);
            this.saveCart(true);
            if (this.cart.timeout === null) {
                this.cart.timeout = this.timeout(true);
            }

            // Build the shopping cart.
            $.each(this.carts, function (cart) {
                d.delegate(cart + ' .' + c.remove, 'click', 'remove', $.proxy(self.listen, self));
                d.delegate(cart + ' :input', 'change', 'cart-options', $.proxy(self.listen, self));
                self.buildCart(cart);
            });
            // Update total amounts.
            this.updateTotals();
            o.ready.call(this);
        }
    }

如果需要名为“init”的函数,只需将其放在函数后面,如下所示:

function init(options) { }
除非您希望通过原型化创建自己的jQuery函数:

jQuery.fn.extend({
    init: function(options){}
})

阅读这里的更多文档:

init:function(
需要附加到一个对象文本,…但是如果你只是想要一个function init,只需执行
function init(选项){
@Keith init不知何故在单词function之前而不是之后,我想我需要有人告诉我这个lol。谢谢。