gpt4 book ai didi

jquery - 我怎样才能让我的幻灯片显示在我的主页上?

转载 作者:太空宇宙 更新时间:2023-11-04 16:18:34 25 4
gpt4 key购买 nike

我在每个页面上都隐藏了我的幻灯片,但我希望它在我的主页上可见,我如何使用 jquery 做到这一点?这是一个现场演示 http://epecho.com/tst/index.html

最佳答案

这是显示/隐藏页面上的幻灯片的 JavaScript:

$(".toggleButton").click(function() {
$("div#sliderSection").slideToggle("slow");
$(".toggleButton").toggle();
});

使用 window.location.href(如 Andreas 所建议的)功能,您应该执行如下操作:

if(window.location.href==url){
$('div#sliderSection').slideToggle('slow');
$('.toggleButton').toggle();
}

我建议进行以下额外修改:

  1. 将显示/隐藏代码重构为一个函数,并在上述两个函数中调用它。
  2. 考虑 url 比较的边缘情况。以下 URL“\index.html”、“\Index.html”、“\”都应该匹配。

希望这对您有所帮助。

鲍勃

关于jquery - 我怎样才能让我的幻灯片显示在我的主页上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7033978/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com