dsg7513 2014-04-21 08:33
浏览 65
已采纳

php回显到html与jquery淡入淡出效果

I am trying to echo php to html, everything works fine but the echo stays on the page until refresh it goes away. anyway I can use jquery to fade in, out it?

part of the php coding:

$q1=mysql_query("SELECT `DEALS` FROM `show` LIMIT 1");
$d1=mysql_fetch_array($q1);
$n2=$d1['DEALS'];
if($n2!=0){

foreach($addresses as $to) { 
mail($to, $subject, $message, $headers);
}
echo'<center><span class="text-wrapper-2 text-wrapper-green">Email Sent!
</span></center>';
}
else{

echo'<center><span class="text-wrapper-2 text-wrapper-red">Email Failed</span></center>';    
}

so the code above echo correctly to html but I would like to add some jquery face effects to it. Any suggestions would be great.

Thanks to all in advance.

  • 写回答

3条回答 默认 最新

  • duanfen2349 2014-04-21 08:39
    关注

    The JavaScript interaction happens entirely client-side, after the PHP is done. So essentially you'd echo the output and then do the client-side effects. So let's say you echo something like this:

    <span class="text-wrapper-2 text-wrapper-green" id="emailMessage" style="display:none;">Email Sent!</span>
    

    Note that I added an id to the element to make it easy to identify. I also gave it an in-line style to not display, since you want it to fade-in first. Feel free to move that styling into CSS as appropriate.

    Then in your client-side code you might have something like this:

    $('#emailMessage').fadeIn(400, function () {
        setTimeout(function () {
            $('#emailMessage').fadeOut();
        }, 5000);
    });
    

    This will fade the element in and then set a timer to fade it back out 5 seconds later.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部