我看到很多插件可以在标签中去除图像的色彩。
但我没有找到任何可以去除背景图像(用作元素(div)背景的图像)的东西。
有没有一种方法可以在悬停时去除背景图像的色彩,而不使用两个背景(即图像精灵一个是黑白的,另一个是彩色的)?
我可以使用图像精灵来实现这样的效果。
// Initially color Image
$(<element>).mouseover(function(e){
jQuery(this).children(":first").stop().animate(
{
'background-position': <some coordinates>
// Coordinates of b&w Image
},
100
);
e.stopPropagation();
})
.mouseout(function(e){
jQuery(this).children(":first").stop().animate(
{
'background-position': <some coordinates>
// Coordinates of color Image
},
100,
settings.easingType
);
e.stopPropagation();
});
但我不想这样。我想动态地使背景图像褪色。 请帮忙。