jQuery UI 选项卡.根据其 id 而不是索引来选择选项卡
问题说明
我有两个选项卡并配置了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?
正确答案
注意:由于对 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
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20 -
希伯来语的空格句子标记化错误
it1352 06-22