如何使用jQuery在下一页上打开特定的滑块 [英] How to open a specific slider on the next page with jQuery

查看:66
本文介绍了如何使用jQuery在下一页上打开特定的滑块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在按下一个按钮时打开下一页上的滑块,但是有多个按钮.此外,当我按下其中一个按钮时,我希望信息滑块打开我在上一页中单击的那个按钮.

I want to open a slider on the next page when pressing a button but there is more than one button. Further, when I press one of the buttons then I want the info slider to open the one I clicked on the previous page.

下面是代码:

$(document).ready(function () {
    $("h3.open-close").click(function () {
        if ($(this).is(".current")) {
            $(this).removeClass("current");
            $(this).next(".desc").slideUp(400);
        } else {
            $(".desc").slideUp(4.00);
            $("h3.open-close").removeClass("current");

            $(this).addClass("current");
            $(this).next(".desc").slideDown(400);
            $(function () {
                if (window.location.hash) {
                    $(window.location.hash).show();
                }
            });
        }
    });
});

推荐答案

您更新的代码:

$(document).ready(function () {
    if (window.location.hash) {
       $(window.location.hash).show(); // <--if true then do this.
    }
    $("h3.open-close").click(function () {
        if ($(this).is(".current")) {
            $(this).removeClass("current");
            $(this).next(".desc").slideUp(400);
        } else {
            $(".desc").slideUp(4.00);
            $("h3.open-close").removeClass("current");

            $(this).addClass("current");
            $(this).next(".desc").slideDown(400);
        }
    });
});

您必须在dom准备就绪时检查哈希.

You have to check for the hash at dom ready.

这篇关于如何使用jQuery在下一页上打开特定的滑块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆