I have a series of tabs with content and want one of the tab/contents to open when a user clicks on a link on a sidebar. How do I do this please in simple terms and instructions. I've managed to set up the tabs using jquery but not really al that js savie!!
Hello Kara,
If the links on your sidebar are true hyperlinks then I would suggest passing something through in the querystring.
It depends what language your site is, but can you not detect something in the querystring of your link and change the visible tab serverside?
Alternatively; using JavaScript, create a function to pick up the variable, that you can fire in the jQuery ready event and change the visible content and focused tab.
something along the lines of (borrowed this from the web):
function querySt(queryvariable)
{
hu = window.location.search.substring(1);
gy = hu.split("&");
for (i=0;i<gy.length;i++)
{
ft = gy[i].split("=");
if (ft[0] == queryvariable)
{
return ft[1];
}
}
}
Fired by: var foobar = querySt("foobar");
There may be a jQuery plugin too.
Just re-read your question; you could disable the defaultaction of the sidebar link click event and perform a jquery statement, so long as the id of you sidebar link somehow related to the content you want to show you should be quids in:
$(".sidebarlink").click(function(e) {
// check this
e.disableDefault();
var linkid = this.id;
$("#content-" + linkid).show();
});
(sorry if the syntax is wrong)