开发者

Javascript: Fade in and out

开发者 https://www.devze.com 2022-12-08 17:02 出处:网络
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 comes in when a mes开发者_JAVA百科sage is send. Looks like this:

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 comes in when a mes开发者_JAVA百科sage 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?


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.com/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 recommend that you should use jquery's fade in and fade out function. for a deeper explanation and code samples please goto: http://docs.jquery.com/Effects/fadeOut

0

精彩评论

暂无评论...
验证码 换一张
取 消