最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

function - Javascript: Fade in and out - Stack Overflow

programmeradmin2浏览0评论

i have this PHP based doc (chatbox) where you can type your message and send it.

Now, i have this fade animation where a message es in when a message is send. Looks like this:

Javascript:

function stateChanged1() 
{ 
if (xmlHttp1.readyState==4)
{ 
document.getElementById("sent").innerHTML="Sent!";
document.writeform.message.value="";
chat();
}
}

in the body:

<span id="sent"></span>

The problem is then it isnt fading out. What do i have to add to the code and where?

i have this PHP based doc (chatbox) where you can type your message and send it.

Now, i have this fade animation where a message es in when a message is send. Looks like this:

Javascript:

function stateChanged1() 
{ 
if (xmlHttp1.readyState==4)
{ 
document.getElementById("sent").innerHTML="Sent!";
document.writeform.message.value="";
chat();
}
}

in the body:

<span id="sent"></span>

The problem is then it isnt fading out. What do i have to add to the code and where?

Share Improve this question asked Oct 19, 2009 at 11:44 Deniz ZoetemanDeniz Zoeteman 10.1k26 gold badges72 silver badges98 bronze badges 1
  • Where is your 'fading out' code? There is nothing to do with fading in the posted snippet. – bobince Commented Oct 19, 2009 at 12:33
Add a ment  | 

4 Answers 4

Reset to default 5

For Effects like fading out use a framework like JQuery, Prototype or MooTools. They will provide you with ample examples how to apply effects to elements.

Add

<script type="text/javascript" src="http://ajax.googleapis./ajax/libs/jquery/1.3.2/jquery.min.js"></script>

to your HTML and add this JavaScript Code:

$("#sent").fadeOut("slow");

after this line:

document.getElementById("sent").innerHTML="Sent!";

try jquery you can fadein and fade out an element easly e.i:

$("#sent").fadeIn("slow");
$("#sent").fadeOut("slow");

i also remend that you should use jquery's fade in and fade out function. for a deeper explanation and code samples please goto: http://docs.jquery./Effects/fadeOut

发布评论

评论列表(0)

  1. 暂无评论