selected class not working jquery function -
the function below show/hides divs tabs can tab between different divs. in addition uses ben alman's bbq plugin http://benalman.com/projects/jquery-bbq-plugin/ allows use button on browser when tabbing between divs.
everything works can't link of clicked tab show 'selected'. when click on tab should add "selected" class link shows selected.
$(function () { var tabcontainers = $('div.tabs > div'); tabcontainers.hide().filter(':first').show(); $(window).bind('hashchange', function () { var hash = window.location.hash || '#divcontainer'; tabcontainers.hide(); tabcontainers.filter(hash).show(); $('div.tabs ul.tabnavigation a').removeclass('selected'); $('a[hash=' + hash + ']').addclass('selected'); }); $(window).trigger( "hashchange" ); });
first save anchor in var @ start of function
var currenct_anchor = $(this);
then
$('div.tabs ul.tabnavigation a').removeclass('selected'); currenct_anchor.addclass('selected');
Comments
Post a Comment