【问题标题】:How can I properly close this jQuery statement如何正确关闭此 jQuery 语句
【发布时间】:2015-12-31 05:31:14
【问题描述】:

我已经在这方面工作了大约 6 个小时。我通过几个 Lint 工具和其他各种在线测试对其进行了处理,但我无法正确关闭以下语句。 最后一行生成了一个持续性错误,Lint 说需要一个 },我在 }、)} }) w/ 和 w/out 的许多其他变体中进行了尝试;以及 2x 3x 或更多右括号、括号和分号的许多其他变体。我检查并重新检查了所有开始和结束语句以确保它们匹配。我想我只是什么都没看到!

如果有一双新的眼睛可以看看这个,看看我错过了什么和做错了什么。

(function ($) {
"use strict";

var slider = null;

$(document).on("mouseover", '.bb_menu_item', function () {
    slider.stopAuto();
    slider.goToSlide($(this).attr('index'));
});

$(document).on("mouseout", '.bb_menu_item', function () {
    slider.startAuto();
});

$(document).ready(function () {
    if ($('#bbSlider').length) {
        slider = $('#bb_slider').bxSlider({
            controls: false,
            pager: false,
            auto: true,
            slideWidth: 1030,
            responsive: true,
            mode:"fade" 
        });
    } 

        $('.tab-linker').click(function () {
        window.location.href = 'http://t.com/?page_id=1302#tab-id-2';
        //return false;
        location.reload(false);
    });

    // Custom homepage slider
    $(".slider-home").click(function (event) {
        event.preventDefault();
        window.location = "http://t.com/";
    });


    //
    $(".slider-services").click(function (event) {
        event.preventDefault();
        window.location = "http://t.com/?page_id=1302";
    });
    //
    $(".slider-gallery").click(function (event) {
        event.preventDefault();
        window.location = "http://t.com/?page_id=73";
    });
    //
    $(".slider-about").click(function (event) {
        event.preventDefault();
        window.location = "http://t.com/?page_id=2";
    });
    //
    $(".slider-contact").click(function (event) {
        event.preventDefault();
        window.location = "http://t.com/?page_id=1167";
    });
    //
    $(".slider-links").click(function (event) {
        event.preventDefault();
        window.location = "http://t.com/?page_id=2565";
    }); 
}); 

【问题讨论】:

标签: javascript jquery


【解决方案1】:

鉴于您的程序以 (function() { 开头(没有缩进!),您需要用 a 关闭您的 IEFE

}());

最后(在与$(document).ready(function () { 匹配的现有}); 之后)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-09
    • 2021-06-12
    • 2020-11-07
    • 2022-08-03
    • 1970-01-01
    • 2012-07-01
    • 2023-03-16
    相关资源
    最近更新 更多