Created
October 30, 2011 04:54
-
-
Save nissuk/1325516 to your computer and use it in GitHub Desktop.
jQuery: hoverOpacity
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
/** | |
* jQuery hoverOpacity | |
* hoverしたときにopacityを指定値まで段階的に変化させ、カーソルが離れたら1まで戻します。 | |
* | |
* # 使用例 | |
* $("a:has(img)").hoverOpacity(0.5); | |
*/ | |
(function($) { | |
var pluginName = "hoverOpacity"; | |
var plugin = function(value, options) { | |
var settings = $.extend({}, plugin.defaults, options); | |
return this.hover( | |
function(){ $(this).stop(true).animate({ opacity: value }, settings) }, | |
function(){ $(this).stop(true).animate({ opacity: 1 }, settings) } | |
); | |
}; | |
plugin.defaults = { duration: "fast" }; | |
$.fn[pluginName] = plugin; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment