dsg7513 2014-04-21 16: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 16: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条)

报告相同问题?

悬赏问题

  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥15 小红薯封设备能解决的来
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答
  • ¥20 在本地部署CHATRWKV时遇到了AttributeError: 'str' object has no attribute 'requires_grad'
  • ¥15 vue+element项目中多tag时,切换Tab时iframe套第三方html页面需要实现不刷新
  • ¥50 深度强化学习解决能源调度问题