更改导航链接的样式 - 包括下一个和上一个按钮

发布于 2024-08-01 21:39:43 字数 377 浏览 3 评论 0原文

我目前正在为一家丹麦公司开发一个网站。 内容全部在一页中,并且我包含了一些 jQuery 滚动之类的内容。 效果很好!

对于菜单,我被要求对元素进行编程,以便活动元素为粗体。 我也这么做过。

问题来了:
客户想要一个主页按钮以及下一个和上一个按钮。 但是,当我单击它们并且页面滚动时,活动元素的 CSS 类不会更改 - 因此菜单中的粗体元素仍然是最后单击的页面。

我希望任何人都可以提供帮助。

该页面可以在以下位置查看: http://vedelform.dk/new/intro/

I'm currently working on a website for a Danish company. The content is all in one page and I've included some jQuery-scrolling and stuff. Works nice!

For the menu I'm asked to programme the elements so the active element is bold. That I've done too.

The problem comes here:
The client wants a home button and a next and previous button. But when I click them and the page scrolls the CSS-classes do not change for the active element - so the bold element in the menu is still the last clicked page.

I hope that anyone can help.

The page can be seen at:
http://vedelform.dk/new/intro/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

可遇━不可求 2024-08-08 21:39:43

除了调用serialscroll插件之外,图像的事件处理程序还需要更新导航链接上适当的类名称。 当您直接单击导航链接时,您会调用changeActiveStates 函数,但主页、下一个和上一个按钮不会发生这种情况。

您应该使用serialScroll插件的onBefore属性来定义一个方法,该方法将确定哪个导航链接应该接收类名。 然后它可以调用changeActiveStates函数。

看起来不需要多几行代码就可以解决您的问题。 如果您需要更多帮助使其正常工作,请告诉我。


编辑:

如果您添加此内容(从 init.js 的第 84 行开始),您应该开始工作:

easing: 'swing',
onBefore:function(e, elem, $pane, $items, pos){
    if ((pos >= 0)&&(pos < $('ul.navigation > li > a').size())) changeActiveStates($('ul.navigation > li > a').get(pos));
    return true;
}

然后您将需要在页面加载时调用changeActiveStates(可能在初始化函数之后)以初始化正确的菜单项。

我希望这会有所帮助; 如果这给您带来更多麻烦,请告诉我。

In addition to calling the serialscroll plugin, the event handler for the images needs to update the appropriate class name on your navigation link. When you click on a navigation link directly, you call the changeActiveStates function, but that isn't happening with the home, next, and previous buttons.

You should use the onBefore attribute of the serialScroll plugin to define a method that will figure out which navigation link is supposed to receive the class name. It can then call the changeActiveStates function.

It doesn't look like it would take more than a few more lines of code to fix your problem. If you need more help getting it to work, let me know.


edit:

If you add this (starting at line 84 of init.js), you should be in business:

easing: 'swing',
onBefore:function(e, elem, $pane, $items, pos){
    if ((pos >= 0)&&(pos < $('ul.navigation > li > a').size())) changeActiveStates($('ul.navigation > li > a').get(pos));
    return true;
}

You will then need to call changeActiveStates (probably after you initialize the function) on page load to initialize the correct menu item.

I hope that helps; let me know if it gives you any more trouble.

笨死的猪 2024-08-08 21:39:43

您使用了缩小版本的脚本,因此很难调试代码。 您也没有向我们提供您使用的插件的名称。 我认为插件中有一个错误。 因为 css 类“selected”会从一个菜单项跳转到另一个菜单项。

You used minified version of scripts so it is very hard to debug the code. Also you didnt give us name of plugin you use. I think there is a bug in plugin. Because css class "selected" sould jump from one menu item to another.

森罗 2024-08-08 21:39:43

@杰森·弗朗西斯:
你也许是对的。 我对 jQuery 和 Javascript 不太感兴趣,到目前为止我所做的更多是运气而不是知识。 我做了很多尝试和错误。
我明白你所说的让serialScroll插件找出调用changeActiveStates的元素 - 但我真的不知道该怎么做。

@Jason Francis:
You're probably right. I'm not that much into jQuery and Javascript and what I've done so far is more luck than it's knowledge. I did A LOT of trial and error.
I understand what you're saying about getting the serialScroll plugin to figure out what element to call changeActiveStates on - but I seriously don't know how to do that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文