开发者

Simplest mutli-fadeing script

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜