having trouble mixing hover add remove class functions with an "active" state for links
- <script type="text/javascript">
- $(document).ready(function(){
- var classes;
- $('span a').hover(function(e){
- // hover on
- classes = $(this).attr('class').split(" ");
- for(var i in classes){
- $('a.' + classes[i]).addClass('sibling').show('slow');
- }
- $(this).addClass('selected');
-
- $('a:not(.selected, .sibling)').addClass('fade').show('slow');
-
- }, function(e){
- $('a').removeClass('selected sibling fade').show('slow');
- });
- });
- </script>
in the aforementioned code I am trying to associate links that are related by class type. this is working. But Im trying to add an "active" state function similar to a:active and it's not flying. I tried the following:
- $('span a').click(function(){
- $(this).addClass('active').show('slow');
- });
it doesnt seem to do anything...and I'm not sure why. I have a class .active which has a different colour set for it, and even a different font size just for debugging purposes...where Im going with this is to instead of just having this dynamic association work by hover also have it by state - so when one link is "active" regardless of where the mouse is, related links are tagged and highlighted appropriately. can anyone help with this?