A simple library that applies gray-scale effect to the images on your page, using JavaScript and CSS only.
Here is the demo.
Include following files into your page:
(function($) {
$(function() {
$(".myimage").imggrayscale();
});
})(jQuery);
Initialize the imggrayscale
, same as $(".myimage").imggrayscale()
.
$(".myimage").imggrayscale("init");
// same effect as $(".myimage").imggrayscale();
When the original image size is changed, call this method to resize the gray-scale effect.
$(window).on("resize", function() {
$(".myimage").imggrayscale("resize");
});
Destroy the gray-scale effect.
$(".myimage").imggrayscale("destroy");
imggrayscale
supports setting parameters during initialization.
When hoverShowOrigin
set to true
, the original image will be shown when mouse over it. (Default is false
)
$(".myimage").imggrayscale({hoverShowOrigin: true});
image-grayscale is released under the MIT License.