/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function mouse_addClass_linkExpand () { $.each(arguments, function() { var hover_class = this.hover_class; var link_expand = this.link_expand; $(this.hover_selector).each(function(){ var selected = $(this); if ( selected.find('a').length == 1) { selected.hover(function() { $(this).addClass(hover_class); }, function() { $(this).removeClass(hover_class); }); } if ( link_expand == true && selected.find('a').length == 1) { selected.click(function(){ var href = $(this).find('a').attr('href'); window.location.href = href; }); } }); }); } // to call it do mouse_addClass_linkExpand ( {hover_selector: '#newsletter .right', hover_class: 'hovered', link_expand: true} );