Log in

View Full Version : show a div onload and hide it few seconds



developerhusain
05-24-2013, 11:06 AM
How can i show a div onload and hide it in few seconds. Can you please help me out

developerhusain

keyboard
05-24-2013, 11:23 AM
$(function() {
$("#testdiv").delay(2000).fadeOut(0);
});


Example:



<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$("#testdiv").delay(2000).fadeOut(0);
});
</script>
</head>
<body>
<div id="testdiv">Test</div>
</body>
</html>

In testing I used a local copy of jQuery because the google hosted version wasn't working for some reason.

jscheuer1
05-25-2013, 09:48 AM
You might want something more elaborate, like:

http://www.dynamicdrive.com/dynamicindex17/stickynote.htm

jscheuer1
05-25-2013, 05:33 PM
In testing I used a local copy of jQuery because the google hosted version wasn't working for some reason.

If you use the URL to the Google hosted jQuery without the protocol:



<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>

the page must be live. For local testing you can use:


<script src="http//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>

Right now Google is hosting that version. But you also have to make sure they are hosting any particular version you want before relying upon them for it.

As far as I can tell, they are not currently hosting 2.0.1, which is the latest, nor 1.10.0, both of which are available on the jQuery home page.

Interestingly though jQuery is now offering both 2.0.1 and 1.10.0 for download, on their api docs page and home page, they're still using 1.9.1.

This is a lot of versions and a lot of changes all at once, even for jQuery. I think that they're moving a little too fast, or should have just waited till version 2 to make so many changes and skipped 1.9+ in the 1 series. But it's up to them what they want to do. Hopefully once the transition to version 2 is well established, the dust will settle to a certain extent.