简体   繁体   English

jQuery淡入?

[英]JQuery fade in?

I want to make a message that fades in the page and then fades out to show the user they logged in on the login before being redirected to the profile, but the message just appears on the screen with no fade, but it does fade off which is good. 我要创建一条消息,该消息在页面中淡出然后淡出以显示他们在重定向到个人资料之前登录的用户,但是该消息仅出现在屏幕上而没有淡出,但是它确实淡出了很好。

This is the code I have for it: 这是我的代码:

echo "
<script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js\">
</script>
<script>
$(function() {
    $('button').click(function() {
        $('p').fadeIn(3000);
        $('p').fadeOut(5000);
    });
});
</script>";
$error = "<meta http-equiv='refresh' content='100; Me'>
   <p style='font-weight:bold;color:green;padding:3px;'>Welcome back $name!</p>";

For fadeIn to work the element has to be hidden first 为了使fadeIn起作用,必须先隐藏元素

$(function () {
    $('button').click(function () {
        $('p').hide().fadeIn(3000).fadeOut(5000);
    });
});

You need to start the page with your <p> element hidden. 您需要在隐藏<p>元素的情况下启动页面。

Just add display:none to the <p> style. 只需将display:none添加到<p>样式即可。

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

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