asifa
asifa

Reputation: 771

change the class of the currently selected tab on next and previous button

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

Answers (2)

asifa
asifa

Reputation: 771

Solved with jquery ui tabs.

Thanks all

Upvotes: 0

Roko C. Buljan
Roko C. Buljan

Reputation: 206121

you could use the method .andSelf()

http://api.jquery.com/andself/

.andSelf().addClass("current");

Upvotes: 1

Related Questions