开发者

Simplest mutli-fadeing script

开发者 https://www.devze.com 2023-03-16 19:33 出处:网络
I\'m looking for script working like on Dr开发者_如何学Cibbble (appearing overlay when you mouse over).

I'm looking for script working like on Dr开发者_如何学Cibbble (appearing overlay when you mouse over). But it must be multi... I mean used for many images on the site. Simple as much.

Thanks!


Using jQuery and hover() mouse event you can achieve the behaviour you want.

$("img").hover(function() { //select the image which is hovered
    $(this).css("opacity","0.5"); //apply opacity for this image

}, function() {
    $(this).css("opacity","1"); //change to opacity to default
});

Demo: http://jsfiddle.net/mVWdQ/

For selector, you can use a class which be used only for the required images instead of an element as img.

Another way is to use animate().

$("img").hover(function() {
    $(this).animate({opacity:0.5},500);

}, function() {
    $(this).animate({opacity:1},500);
});

Demo: http://jsfiddle.net/mVWdQ/1/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号