jQuery tabs. Open certain tab from a certain position. Possible?
I am using jQuery tabs on my site and have an article on one of the tabs and comments on the other. Would it be possible to link from the article tab to the comments tab and open it from a certain position defined with an "a name" attribute?
The jQuery UI 1.8.4 release added a feature you may be interested in:
TABS The tabs plugin has been updated to allow accessing tabs by href in addition to index. The enable, disable, select, load, and remove methods all accept the href of a tab.
For example, what you want may look like this:
For the scrolling you can just do a window.location or use something else like the scrollTo() plugin for more utility.
$("#tabs").tabs("select", "#comments"); $("#comments").scrollTo("#comment-1234");
Since the tab itself needs to be selected with the hash anchor, you probably can't do it in a straightforward way.