Posted By

joe-bbb on 10/29/09


Tagged

link hover expand


Versions (?)

mouse_addClass_linkExpand


 / Published in: jQuery
 

  1. function mouse_addClass_linkExpand () {
  2.  
  3. $.each(arguments, function() {
  4. var hover_class = this.hover_class;
  5. var link_expand = this.link_expand;
  6.  
  7. $(this.hover_selector).each(function(){
  8. var selected = $(this);
  9. if ( selected.find('a').length == 1) {
  10. selected.hover(function() {
  11. $(this).addClass(hover_class);
  12. },
  13. function() {
  14. $(this).removeClass(hover_class);
  15. });
  16. }
  17.  
  18. if ( link_expand == true && selected.find('a').length == 1) {
  19. selected.click(function(){
  20. var href = $(this).find('a').attr('href');
  21. window.location.href = href;
  22. });
  23. }
  24.  
  25. });
  26. });
  27. }
  28.  
  29. // to call it do
  30.  
  31. mouse_addClass_linkExpand (
  32. {hover_selector: '#newsletter .right', hover_class: 'hovered', link_expand: true}
  33. );

Report this snippet  

You need to login to post a comment.