Created
May 19, 2016 12:23
-
-
Save jbuncle/9bc6a64962e133bdc37698f4d8769d26 to your computer and use it in GitHub Desktop.
Simple jQuery Plugin which fades out an elements siblings on hover.
This file contains 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
/*! | |
* Simple jQuery Plugin which fades out an elements siblings on hover. | |
* | |
* Copyright 2016 James Buncle | |
* | |
* Released under the MIT license. | |
* http://jquery.org/license | |
* | |
*/ | |
(function ($) { | |
$.fn.siblingFader = function () { | |
var $selection = $(this); | |
return this.each(function () { | |
var $hovered = $(this); | |
var $siblings = $selection.not($hovered); | |
$(this).hover(function (event) { | |
$hovered.stop().animate({ | |
opacity: 1 | |
}); | |
$siblings.stop().animate({ | |
opacity: 0.5 | |
}); | |
}, function (event) { | |
$siblings.stop().animate({ | |
opacity: 1 | |
}); | |
$hovered.stop().animate({ | |
opacity: 1 | |
}); | |
}); | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment