0

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 ?

Community
  • 1
  • 1
Haxed
  • 2,887
  • 14
  • 47
  • 73
  • Please read the [answer][1]. [1]: http://stackoverflow.com/questions/5509895/i-need-to-add-custom-css-to-jquery-tabs-when-it-is-selected-how – Haxed Apr 04 '11 at 08:09
  • I really don't think this should be closed as much as it should be changed in context. What I mean to say is, the question is "misdirected". You don't need to use jQuery to do what he wants to do, you can use simple CSS using the jQuery classes that are automatically added when tabs are created. Example: `.ui-tabs-selected { background-image: url(http://...); }`, or for the panel `.ui-tabs-panel:not(.ui-tabs-hide) { background-image: url(http://...); }` – SpYk3HH Aug 26 '12 at 23:43

1 Answers1

0

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".

Community
  • 1
  • 1
Tom Glenn
  • 1,982
  • 4
  • 16
  • 26
  • can u help me with this part of the code $(selected tab).css("background-image","url stuff.."); – Haxed Apr 01 '11 at 10:56