【问题标题】:jQuery Tools Tabs - Named Anchors?jQuery 工具选项卡 - 命名锚?
【发布时间】:2012-03-14 00:29:21
【问题描述】:

jQuery Tools Tabs v1.2 让我陷入了一个问题。下面我来给大家看一下这个问题。

<ul class="tabs">
<li><a href="#anchor">This is an item</a></li>
<li><a href="#anchor">This is an item</a></li>
<li><a href="#anchor">This is an item</a></li>
</ul>

<h1><a name="anchor></a>This Is The Header Where The Anchor Resides</h1>
<div class="panes">
<div>Here's the first item's content</div>
<div>Here's the second item's content</div>
<div>Here's the third item's content</div>
</div>

我想要做的是,当您单击每个项目时,您会被下拉到新内容,因此会出现新的 div。而不是只是点击离开而不是让您的窗口位于新 DIV 的顶部。

问题?我有理由相信 jQuery Tools > Tabs Script 会自动在插件的某处执行return false;。这不允许我在链接属性中添加任何href="#anchor"。它没有通过窗口/页面的位置显示,也没有显示在地址栏上。

我会直接去 jQuery Tools 的论坛询问,但他们的论坛/支持似乎已经坏了......就像网站其余部分的大部分内容一样,当然 Stack Overflow 最终会更好,并且有过去对我好很多。

您可以在这里查看标签系统: http://jquerytools.org/demos/tabs/index.html

您可以在此处查看选项卡系统文档: http://jquerytools.org/documentation/tabs/index.html

您可以在此处查看选项卡系统 jQuery/JavaScript: http://cdn.jquerytools.org/1.2.6/full/jquery.tools.min.js

感谢大家的帮助!

【问题讨论】:

标签: javascript jquery tabs anchor


【解决方案1】:

在初始化选项卡时使用{history : true} 选项

检查此链接 http://jquerytools.org/demos/tabs/history.html

【讨论】:

  • 谢谢您,先生,这最终效果很好,但您的答案就是答案。但是,现在,它已经消失了。不过,谢谢。
【解决方案2】:
jQuery().ready(function () {
         jQuery('ul.tabs a').click(function(){
                 jQuery(window).scrollTop( jQuery('a[name="anchor"]').position().top );
         });
}

几分钟前提供此答案的人是谁,我假设已将其删除。这就是答案! :)。非常感谢!

我也在使用友好的 URL 运行 MODx。所以这成功了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多