jQuery 动画切换

发布于 2024-10-17 06:04:00 字数 1236 浏览 10 评论 0原文

我正在尝试创建如下所示的动画效果。

// JavaScript Document
$(document).ready(function () {
    $('.lovebtn').click(function () {
        $('.love').animate({
            height: '672px'
        }, 1000, function () {
            $('.lovetxt').css("display", "block");
            $(".lovebtn .button").attr("src", "images/btn_love_close.gif");

        });

    });


    // Lust
    $('.lustbtn').click(function () {
        $('.lust').animate({
            height: '672px'
        }, 1000, function () {
            $('.lusttxt').css("display", "block");
            $(".lustbtn .button").attr("src", "images/btn_lust_close.gif");

        });

    });


    //luxuary
    // Lust
    $('.luxurybtn').click(function () {
        $('.maskbg').css("display", "block");
        $('.luxury').animate({
            height: '1056px'
        }, 1000, function () {
            $('.luxurytxt').css("display", "block");
            $(".luxurybtn .button").attr("src", "images/btn_luxury_close.gif");

        });

    });
});

http://uniquedl.com/3closets/index.html

当您进入上述页面并单击爱情欲望和奢侈上的三个按钮。你会得到一系列的效果。当我单击同一个按钮时,我不想反转效果。

有什么建议我该怎么做吗?

I am trying to create an animate effect like the following.

// JavaScript Document
$(document).ready(function () {
    $('.lovebtn').click(function () {
        $('.love').animate({
            height: '672px'
        }, 1000, function () {
            $('.lovetxt').css("display", "block");
            $(".lovebtn .button").attr("src", "images/btn_love_close.gif");

        });

    });


    // Lust
    $('.lustbtn').click(function () {
        $('.lust').animate({
            height: '672px'
        }, 1000, function () {
            $('.lusttxt').css("display", "block");
            $(".lustbtn .button").attr("src", "images/btn_lust_close.gif");

        });

    });


    //luxuary
    // Lust
    $('.luxurybtn').click(function () {
        $('.maskbg').css("display", "block");
        $('.luxury').animate({
            height: '1056px'
        }, 1000, function () {
            $('.luxurytxt').css("display", "block");
            $(".luxurybtn .button").attr("src", "images/btn_luxury_close.gif");

        });

    });
});

http://uniquedl.com/3closets/index.html

when you go the the ablove page and click the three buttons on either love lust and luxury. you get a series of effects. when i click the same button i wannt reverse the effect .

any tips how i can do it ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

意中人 2024-10-24 06:04:00

我只会为爱按钮显示几乎相同的其他只是不同的高度和CSS选择器当然

$('.lovebtn').click(
     $('.love').toggle(  
         function() {  
             $('.love').animate({  
                 height: '672px'   
             }, 1000, function () {  
                 $('.lovetxt').css("display", "block");  
                 $(".lovebtn .button").attr("src", "images/btn_love_close.gif");  
             }    
        },    
        function() {    
            $('.love').animate({    
                height: '480px'    
            }, 1000, function () {    
                $('.lovetxt').css("display", "none");  
                $(".lovebtn .button").attr("src", "images/btn_love_open.gif");  
            }    
        }  
    );  
);

抱歉我在将代码放在正确的布局中时遇到问题:(你可以在这里检查http://jsfiddle.net/dKyku/

基本上,单击链接即可在两部分代码之间切换,一部分显示该部分,第二部分隐藏它/将其放回原始布局。

I will show only for the love buttonm almost the same for other just different height and CSS selectors of course

$('.lovebtn').click(
     $('.love').toggle(  
         function() {  
             $('.love').animate({  
                 height: '672px'   
             }, 1000, function () {  
                 $('.lovetxt').css("display", "block");  
                 $(".lovebtn .button").attr("src", "images/btn_love_close.gif");  
             }    
        },    
        function() {    
            $('.love').animate({    
                height: '480px'    
            }, 1000, function () {    
                $('.lovetxt').css("display", "none");  
                $(".lovebtn .button").attr("src", "images/btn_love_open.gif");  
            }    
        }  
    );  
);

Sorry I have problems putting the code in right layout :( You could check it here http://jsfiddle.net/dKyku/

Basically on clicking the link you toggle between two portions of code, one showing the section, and second one hiding it/putting it back to its original layout.

疏忽 2024-10-24 06:04:00

您还可以通过添加额外的类来做到这一点,如下所示

   $('.lovebtn').click(function (){
   if (!$(this).hasClass('reverse')) {
    hasClickedLove = true;
    $('.love').animate({
        height: '672px'
    }, 1000, function () {
        $('.lovetxt').css("display", "block");
        $(".lovebtn .button").attr("src", "images/btn_love_close.gif");
    });
  $(this).addClass('reverse);

 }//end if
 else if(hasClass('reverse')) {
    $(this).removeClass('reverse);
    //animation code
   }
});

You can also do this by adding extra class like this

   $('.lovebtn').click(function (){
   if (!$(this).hasClass('reverse')) {
    hasClickedLove = true;
    $('.love').animate({
        height: '672px'
    }, 1000, function () {
        $('.lovetxt').css("display", "block");
        $(".lovebtn .button").attr("src", "images/btn_love_close.gif");
    });
  $(this).addClass('reverse);

 }//end if
 else if(hasClass('reverse')) {
    $(this).removeClass('reverse);
    //animation code
   }
});
人间不值得 2024-10-24 06:04:00

插入一个布尔值,如下所示:

$('.lovebtn').click(function () {
    if ( !hasClickedcLove) {
        hasClickedLove = true;
        $('.love').animate({
            height: '672px'
        }, 1000, function () {
            $('.lovetxt').css("display", "block");
            $(".lovebtn .button").attr("src", "images/btn_love_close.gif");
        });
    }//end if
    else {
        hasClickedLove = false;
        //animation code
    }
});

Insert a boolean value, like this:

$('.lovebtn').click(function () {
    if ( !hasClickedcLove) {
        hasClickedLove = true;
        $('.love').animate({
            height: '672px'
        }, 1000, function () {
            $('.lovetxt').css("display", "block");
            $(".lovebtn .button").attr("src", "images/btn_love_close.gif");
        });
    }//end if
    else {
        hasClickedLove = false;
        //animation code
    }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文