• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

jQuery UI 选项卡.根据其 id 而不是索引来选择选项卡

用户头像
it1352
帮助1

问题说明

我有两个选项卡并配置了usign jQuery UI.

I have two tabs and configured usign jQuery UI.

ul   
  li  tabone
  li tabtwo
ul

动态地从后面的 C# 代码中隐藏或选择一些选项卡,比如说 tabtwo另一个选项卡必须隐藏或不显示.我可以使用 .tabs({selected:1});.tabs(disable:0). 在 JavaScript 中执行此操作,但我不想使用选项卡这样做的索引.

dynamically from C# code behind I will hide or select some tab let say tabtwo and the other tab has to be hidden or not shown. I can do this in JavaScript using .tabs({selected:1}); and .tabs(disable:0). but I don't want to use the tab indexes to do so.

是否有任何替代方法可以根据名称/ID 选择选项卡?

Is there any alternate to select tabs based on their name/id?

正确答案

#1

注意:由于对 jQuery 1.9 和 jQuery UI 的更改,此答案不再正确.请参阅下面@stankovski 的回答.

您需要首先找到选项卡的索引(这只是它在列表中的位置),然后使用 jQuery UI 提供的选择事件专门选择选项卡(选项卡->选择).

You need to find the tab's index first (which is just its position in a list) and then specifically select the tab using jQuery UI's provided select event (tabs->select).

var index = $('#tabs ul').index($('#tabId'));
$('#tabs ul').tabs('select', index);

更新:顺便说一句 - 我确实意识到这(最终)仍然是按索引选择的.但是,它不需要您知道选项卡的具体位置(特别是当它们按照问题中的要求动态生成时).

Update: BTW - I do realize that this is (ultimately) still selecting by index. But, it doesn't require that you know the specific position of the tabs (particularly when they are dynamically generated as asked in the question).

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tangjcbfb
系列文章
更多 icon
同类精品
更多 icon
继续加载