jquery UI 选项卡使用 DIV 而不是 UL 进行导航

发布于 2024-08-01 18:19:53 字数 662 浏览 2 评论 0原文

我对 JS 有点陌生,这让我抓狂了。

我想使用内部带有一堆锚点的 DIV 进行导航,而不是强制的(我认为?)UL。

我找到了执行此操作的代码段,但我似乎无法理解它。

    this.list = this.element.children('ul:first');
    this.lis = $('li:has(a[href])', this.list);
    this.anchors = this.lis.map(function() { return $('a', this)[0]; });
    this.panels = $([]);

现在,将 更改

ul:first

div:first 

有效,但我仍然必须将所有 A 包含在 LI 中。 这肯定发生在第二行,但我真的不知道该怎么办。

我知道这只是一个相当大的脚本的一小部分,但我希望它能做到。 所有代码都可以在 ui.jquery.com 上找到(您很可能已经知道),如果需要,我可以发布其余部分。

非常感谢您的帮助。

目标是用一个只包含 A 的 DIV 替换 UL 和 LI 这将使造型变得更加容易。

Im a little new to JS and this has got me scratching my head like crazy.

I want to use a DIV with a bunch of anchors inside for the navigation instead of the mandatory (I think?) UL.

I have found the piece of code that does this, but I can't seem to make any sense of it.

    this.list = this.element.children('ul:first');
    this.lis = $('li:has(a[href])', this.list);
    this.anchors = this.lis.map(function() { return $('a', this)[0]; });
    this.panels = $([]);

Now, changing the

ul:first

to

div:first 

works, but I still have to wrap all my A's in a LI.
This must be happening in the second line, but I really can't figure out what to do with it.

I know this is a small bite of a rather large script, but I hope it will do.
All the code is available at ui.jquery.com (as you most likely already know) and I can post the rest of it if needed.

Many thanks in advance for your help.

The goal is to replace the UL and LI's with a single DIV that contains nothing but A's
This will make styling so much easier.

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

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

发布评论

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

评论(1

三生路 2024-08-08 18:19:53
this.list = this.element.children('div');
this.lis = $('a[href]', this.list);
this.anchors = $('a[href]', this.list);
this.panels = $([]);

尝试这个。

我说的有点太快了,但是很容易解决。 只是将其添加到此处以供其他可能正在寻找它的人使用。 Chacha 的解决方案有效,但选项卡在被选择时不会被分配适当的类。 通过从 ui.tabs.js 中的第 273 行和第 281 行删除 .closest('li') 可以解决此问题。这将很好地解决此问题,您可以像平常一样使用这些类。 – Mathias Nielsen 12 分钟前

this.list = this.element.children('div');
this.lis = $('a[href]', this.list);
this.anchors = $('a[href]', this.list);
this.panels = $([]);

Try this.

And I said that a little to soon, but it was easy to fix. Just adding it here for anyone else that might be looking for it. Chacha's solution works, but the tabs wont be assigned the proper classes when they are selected. This is fixed by removing .closest('li') from lines 273 and 281 in ui.tabs.js This will fix it nicely and you can use the classes as you would normally. – Mathias Nielsen 12 mins ago

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