简体   繁体   English

用于单击淡出一个 div 然后淡入另一个 div 然后反向执行的按钮的 jQuery

[英]jQuery for clicking on a button which fades out one div and then fades in another and then to do it in reverse

How do you write jQuery for clicking on a button which fades out one div and then fades in another and then clicking another button that does the reverse.你如何编写 jQuery 来单击一个按钮,该按钮淡出一个 div,然后淡入另一个 div,然后单击另一个执行相反操作的按钮。

I am really stuck at the half way mark.我真的被困在中途标记处。 With the code below I am able to fade out the div and fade in another but unsure on how to do the opposite.使用下面的代码,我可以淡出 div 并淡入另一个,但不确定如何做相反的事情。

Could really do with your expert help on this task.真的可以在您的专家帮助下完成这项任务。 Would be much appreciated - thanks.将不胜感激 - 谢谢。

$(document).ready(function() {
    $('#triggerButton1').click(function(e){
        $('#homepagetext').fadeOut('slow', function(){
            $('#contactform').fadeIn('slow');
        });
    });
    $('#triggerButton2').click(function(e){
        $('#contactform').fadeOut('fast', function(){
            $('#homepagetext').fadeIn('slow');
        });
    });
});

Your code seems to be working fine in a fiddle: https://jsfiddle.net/05q2m4to/您的代码似乎在小提琴中工作正常: https : //jsfiddle.net/05q2m4to/
The only thing that seems weird to me is having one fade go fast and all the other ones slow but that doesn't break anything.唯一对我来说似乎很奇怪的是让一个淡入淡出fast而所有其他淡化都slow但这并没有破坏任何东西。

Maybe the problem is somewhere outside the script?也许问题出在脚本之外?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM