Add CSS class to selected link
Hey all!
I'm building a calendar and using a jQuery script to shift between "list view" and "calendar view". The thing is, that I would like to add a unique CSS class to the selected link, so I can make a highlight effect (or something like that) that only applies to the currently selected link. My script is:
- jQuery(document).ready(function(){
- //if this is not the first tab, hide it
- jQuery(".tab:not(:first)").hide();
-
- //to fix u know who
- jQuery(".tab:first").show();
-
- //when we click one of the tabs
- jQuery(".htabs a").click(function(){
- //get the ID of the element we need to show
- stringref = jQuery(this).attr("href").split('#')[1];
- //hide the tabs that doesn't match the ID
- jQuery('.tab:not(#'+stringref+')').hide();
- //fix
- if (jQuery.browser.msie && jQuery.browser.version.substr(0,3) == "6.0") {
- jQuery('.tab#' + stringref).show();
- }
- else
- //display our tab fading it in
- jQuery('.tab#' + stringref).show();
- //stay with me
- return false;
- });
-
- });
As I'm completely new to jQuery and didn't even write this script myself, I don't know how to do this. I've tried adding:
- jQuery(this).addClass('active');
But it didn't work out that well...