Created
October 28, 2008 23:09
-
-
Save collin/20545 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When hovering over an anchor | |
// find all anchors with the same href attribute | |
// and give them all a 'hover' class | |
;(function(_){ | |
jQuery.fn.extend({ | |
attrSelector: function(attr) { | |
return '[' | |
+ attr | |
+ '="' | |
+ this.attr(attr) | |
+ '"]'; | |
}, | |
matchingAttribute: function(attr) { | |
return $(this.attrSelector(attr)); | |
} | |
}); | |
_(function() { | |
_('a').hover( | |
function(){ | |
_(this).matchingAttribute('href').addClass('hover'); | |
} | |
,function() { | |
_(this).matchingAttribute('href').removeClass('hover'); | |
} | |
); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment