[jQuery]hover時のopacity設定まとめ

WordPress
スポンサーリンク

jQuery

リンクタグに適用

$(document).ready(function() {
    $('a').hover(
        function(){
            $(this).animate({opacity: 0.75},200)
        },function(){
            $(this).animate({opacity: 1},200)
    });
});

.hoverクラスのリンクタグに適用

$(document).ready(function() {
    $('a.hover').hover(
        function(){
            $(this).animate({opacity: 0.75},200)
        },function(){
            $(this).animate({opacity: 1},200)
    });
});

特定の要素(hogeクラス)を除いたリンクに適用

$(document).ready(function() {
    $('a:not(.hoge)').hover(
        function(){
            $(this).animate({opacity: 0.75},200)
        },function(){
            $(this).animate({opacity: 1},200)
    });
});

コメント

タイトルとURLをコピーしました