tetris
tetris

Reputation: 4372

How to add direct link to tabbed menu

I have just found this simple jQuery tabbed menu:

http://jqueryfordesigners.com/demo/tabs.html

How can I add to it absolutes links to every content of the tabs? I explain: If, for example, the user enters http://xxxx.com/mypage.php#Second, the tab contents second should become tabbed (opened). Is there a simple way to add this feature to this menu?

Upvotes: 0

Views: 501

Answers (1)

user113716
user113716

Reputation: 322622

For this link (notice the lowercase "s" in "second" to match your example):

http://xxxx.com/mypage.php#second

Try this:

  // get the hash from the location
var tab = window.location.hash;

  // get the <a> element with the href that matches the location hash,
  //    and fire a click event on it
$('div.tabs ul.tabNavigation a[href=' + tab + ']').click();

Upvotes: 1

Related Questions