如何在 jQuery 中获取当前选定的选项卡以进行 css 样式设置?
我有一段代码可以在选择选项卡时显示消息,但现在我想在选择选项卡时向所选选项卡添加背景图像。
这是代码:
<script type="text/javascript">
$(function(){
$("#myTabs").bind("tabsselect", function(e, tab) {
alert("The tab at index " + tab.index + " was selected");
});
$("#myTabs").tabs();
});
</script>
我认为类似 ($selected tab).css("background-image","url stuff..");应该可以,但我不知道当前所选选项卡的语法。
有什么想法吗?
Possible Duplicate:
I need to add custom css to jquery tabs when it is selected, how ?
I have a code to display a message when a tab is selected, but now I want to add a background image to the selected tab when it is being selected.
Here is the code:
<script type="text/javascript">
$(function(){
$("#myTabs").bind("tabsselect", function(e, tab) {
alert("The tab at index " + tab.index + " was selected");
});
$("#myTabs").tabs();
});
</script>
I think something like ($selected tab).css("background-image","url stuff.."); should work but I do not know the syntax for the currently selected tab.
Any Idea ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅: jQuery UI 选项卡获取当前选定的选项卡索引
另外,建议将标题更改为更合适的内容,例如“How do I get the current selected tab in jQuery”。
See: jQuery UI Tabs Get Currently Selected Tab Index
Also, suggest changing your title to something more appropriate like "How do I get the currently selected tab in jQuery".