获取正在激活的标签页(div)的ID [英] Get the ID of the tab (div) being activated
本文介绍了获取正在激活的标签页(div)的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用jQuery 1.9和jQuery UI 1.10
I'm using jquery 1.9 and jquery UI 1.10
我希望能够在单击选项卡时获得选项卡ID.例如,如果我单击名为第二"的选项卡,我想获得"tabs-2"响应.
I want to be able to get the tab ID when clicking on a tab. For example if I clicked tab named "Second" I want to get "tabs-2" response.
到目前为止,我已经完成了以下代码:
I've done the below code so far:
<script type="text/javascript">
$(function () {
$("#tabs").tabs({
beforeActivate: function (event, ui) {
alert(/* the id of the tab (div) being activated */);
}
});
});
</script>
<div id="tabs">
<ul>
<li><a href="#tabs-1">First</a></li>
<li><a href="#tabs-2">Second</a></li>
</ul>
<div id="tabs-1">
<p>abcde</p>
</div>
<div id="tabs-2">
<p>fghi</p>
</div>
</div>
推荐答案
经过测试并与JQueryUI 1.10一起使用,如何在选择时获取标签的ID:
Tested and working with JQueryUI 1.10, how to get the ID of the tab as it is selected:
$("#tabs").tabs({
beforeActivate: function (event, ui) {
alert(ui.newPanel.attr('id'));
}
});
这篇关于获取正在激活的标签页(div)的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文