开发者

Tab Menus: Change what tab is focused on page load?

At the bottom of this page I have a tab menu. It works, but we 开发者_如何学Goneed the 2nd tab to be focused "current release," on page load and not the first ("previous release").

I've tried different things (added class="active" to the 2nd tab's li), but no success thus far.

Anyone know how to accomplish this?


This is probably generally better to do this on the server, but if you're OK with a client-side solution (since the question is tagged jQuery), you could just do this:

$(function() {
  $('ul .current-release').click();
});


I just realised that you are not using the jQuery UI Tabs. I think you should seriously thinking about switching to it. It makes your life much easier. Take a look at the demos: http://jqueryui.com/demos/tabs/.

Once you're using jQuery UI Tabs, you can simply initiate the tabs with the selected option:

$( "#tabs" ).tabs({ selected: 1 });


First you should find out how focusing works for the first tab. Have it active class on li element or on some other element inside that?

Second you should see if there is any client-side script at work or not? Some tab-based systems like Telerik Tabs use cookies and client-side JavaScript to focus the current tab.

Third you should see if the tab doesn't get highlighted and focused from server. Sometimes in spite of all client-side attempt, server does something behind the scenes. (Of course this has meaning, only if you haven't written the server-side code).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜