How to Change the url of the page when jquery ui tabs is clicked

Posted by Aakash Chakravarthy on Stack Overflow See other posts from Stack Overflow or by Aakash Chakravarthy
Published on 2010-06-14T07:47:57Z Indexed on 2010/06/14 7:52 UTC
Read the original article Hit count: 304

Filed under:
|
|

Hello,

I have jquery tabs list like

<ul id="tabsList">
      <li><a href="#tab-1">TAB 1</a></li>
      <li><a href="#tab-2">TAB 2</a></li>
      <li><a href="#tab-3">TAB 3</a></li>
</ul>

and contents for it like

<div id="tab-1">...</div>, <div id="tab-2">...</div>, <div id="tab-3">...</div>

When the tab is clicked, the tab changes correctly.

But i want the id of the tabs be in the url.

i.e when tab 2 is clicked, the URL should change to http://example.com/index.htm#tab-2

when tab 1 is clicked, the URL should change to http://example.com/index.htm#tab-1

How to do this ?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-ui