使用 jquery 禁用前一个元素的链接
现在我有一个像这样的站点地图:主页>关于我们>我们是谁。我可以使用 jQuery 禁用“关于我们”离开主页的链接仍然处于活动状态吗?另外如果站点地图增加到这个级别首页>服务>咨询>>业务>训练。使用 jQuery 禁用业务、咨询和服务链接,但仍使“主页”链接处于活动状态是否可以实现。
提前致谢
Now I have a sitemap such as this: Home > About Us > Who we Are. Can I use jQuery to disable the link for About Us leaving Home to be still active? Also if the site map increases to this level Home > Services > Consulting > Business > Training. Would it be achievable using jQuery to disable the Business, consulting and Services link, but still making the 'Home' link active.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
http://jsfiddle.net/HTGBE/2/
和 JS:
http://jsfiddle.net/HTGBE/2/
and the JS:
我认为需要更多信息才能为您提供您想要的信息 - 例如您是否试图保持第一个链接处于活动状态?或者文本中带有“Home”的第一个链接?
无论如何,这样的事情听起来就像你所追求的:
I think a little more information is needed to give you exactly what you want - for example are you trying to keep the first link active? Or the first link with "Home" in its text?
Regardless, something like this sounds like what you're after:
如果没有看到实际的 HTML,很难准确地说出来,但它应该很容易做到。假设您的 HTML 如下所示:
您想要做的是将除第一个锚点之外的所有锚点更改为具有相同内容的跨度。每次页面加载到文档就绪处理程序中时都运行此命令。请注意,您可能需要根据需要添加类/css 以保持正确的样式。
It's hard to say exactly without seeing your actual HTML, but it should be easily doable. Let's say your HTML looks like:
What you want to do is change all the anchors except the first to span's with the same content. Run this every time the page loads in a document ready handler. Note that you may need to add classes/css as necessary to maintain the correct styling.