开发者

jQuery and mouseover issue

开发者 https://www.devze.com 2022-12-31 15:27 出处:网络
I have the following code: $(\'a.home-page-link\').mouseover(function() { 开发者_运维问答$(this).animate({

I have the following code:

$('a.home-page-link').mouseover(function() {
      开发者_运维问答  $(this).animate({
            opacity:    0.4
        }, 200, function());
    });

For some reason, this refuses to "play ball", any ideas?

Cheers!


Try adding {} to the second function

$('a.home-page-link').mouseover(function() {
        $(this).animate({
            opacity:    0.4
        }, 200, function() { } );
    });


$('a.home-page-link').mouseover(function() {
        $(this).animate({
            opacity:    0.4
        }, 200, function(){});
    });

make sure your callback function is declared correctly. then it should work. test it here: http://jsfiddle.net/5XwKG/


Not sure if you just forgot to paste something but the third argument to .animate() - function() will throw an error as there is no function body defined: function() {} or just leave that last argument off might help.


If you don't need the callback function, leave it out:

$('a.home-page-link').mouseover(function() {
    $(this).animate({
        opacity: 0.4
    }, 200);
});


Tried this? It works for me...

$(document).ready(function() 
{   
        $('a.home-page-link').mouseover(function() 
        {
            $(this).animate({opacity:0.4}, 200);
        });       
});
0

精彩评论

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

关注公众号