Reputation: 771
I want to change the css class of the currently selected tab on the click of the next and previous button. The next and previous click is working fine. However I also want to change the css class of the currently selected tab.
$(".next-tab").click(function () {
var selected = $("#tab-div").tabs("option", "selected");
$("#tab-div").tabs("option", "selected", selected + 1);
});
$(".prev-tab").click(function () {
var selected = $("#tab-div").tabs("option", "selected");
$("#tab-div").tabs("option", "selected", selected - 1).addClass("current");
var selected_tab = $(this).find("a").attr("href");
$("#tab-div li a:not(first)").removeClass("current");
$("#tab-div li a:first").addClass("current");
});
Any advice or suggestions?
Thanks,
Upvotes: 1
Views: 131
Reputation: 206121
you could use the method .andSelf()
http://api.jquery.com/andself/
.andSelf().addClass("current");
Upvotes: 1