如果选择了某个 jquery ui 选项卡,则显示/隐藏链接
单击 #my-text-link 时,我需要选择选项卡 5,选择选项卡 5 时,我需要隐藏 #my-text-link。希望这是有道理的,这是代码,也是我到目前为止所做的,请随时向我展示更好的方法。提前致谢
var $tabs = $('.tabbed').tabs(); // first tab selected
$('#my-text-link').click(function() { // bind click event to link
$tabs.tabs('select', 4); // switch to third tab
$('#my-text-link').hide();
return false;
});
<a href="#" id="my-text-link"></a>
<ul>
<li class="one"><a href="#tabs-1" title="Summary"></a></li>
<li class="two"><a href="#tabs-2" title="Detailed Info"></a></li>
<li class="three"><a href="#tabs-3" title="Images"></a></li>
<li class="four"><a href="#tabs-4" title="Reviews"></a></li>
<li class="five"><a href="#tabs-5" title="Dates & Prices"></a></li>
</ul>
<div id="tabs-1"></div>
<div id="tabs-2"></div>
<div id="tabs-3"></div>
<div id="tabs-4"></div>
<div id="tabs-5"></div>
When #my-text-link is clicked, i need to select tab 5 and when tab 5 is selected i need to hide #my-text-link. hope this makes sense, heres the code, and also what I have done so far, please feel free to show me a better way. Thanks in advance
var $tabs = $('.tabbed').tabs(); // first tab selected
$('#my-text-link').click(function() { // bind click event to link
$tabs.tabs('select', 4); // switch to third tab
$('#my-text-link').hide();
return false;
});
<a href="#" id="my-text-link"></a>
<ul>
<li class="one"><a href="#tabs-1" title="Summary"></a></li>
<li class="two"><a href="#tabs-2" title="Detailed Info"></a></li>
<li class="three"><a href="#tabs-3" title="Images"></a></li>
<li class="four"><a href="#tabs-4" title="Reviews"></a></li>
<li class="five"><a href="#tabs-5" title="Dates & Prices"></a></li>
</ul>
<div id="tabs-1"></div>
<div id="tabs-2"></div>
<div id="tabs-3"></div>
<div id="tabs-4"></div>
<div id="tabs-5"></div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我从您的代码中看到,您已经成功在单击链接时打开了一个选项卡。以下是用户打开选项卡时隐藏链接的方法:
希望这有帮助
As far as I can see from your code, you've already managed to open a tab when the link is clicked. Here's how you hide the link when user opens the tab:
Hope this helps