weixin_33717298 2011-10-17 05:10 采纳率: 0%
浏览 42

如何淡入淡出?

Suppose I use JQuery to do an ajax call, and the result is returned in HTML.

I want to add this result to my current page.

$("#tweets").prepend(result);

result is a string of html code.

This works. However, it just appears. I want it to fadeIn(400). How can I make it fade in?

  • 写回答

1条回答 默认 最新

  • weixin_33717117 2011-10-17 05:12
    关注

    Make the HTML hidden by default. If you tell the browser to fade in an element that is already shown, it'll do nothing (which is what you're experiencing).

    For example, you could wrap the result HTML in a div tag with the class ResponseData. Then, in CSS, you could add this rule:

    div.ResponseData
    {
        display: none;
    }
    

    Now, as soon as that data is prepended into the tweets area, it'll be hidden. Then, your fadein call will work as desired.

    Your Javascript would look something like this:

    $("#tweets").prepend(result);
    $("div.ResponseData").fadeIn();
    
    评论

报告相同问题?

悬赏问题

  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 哪个tomcat中startup一直一闪而过 找不出问题
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳
  • ¥15 springboot 3.0 实现Security 6.x版本集成