0
How can I Display div with JavaScript !!
I wanna display a div from right after page finish loading !!
4 Answers
+ 10
Maybe he want to display a "div" not yet created.
Something like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
window.onload = function() {
var div = document.createElement('div');
document.body.appendChild(div);
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please, for the next time, be more specific ^_^
+ 3
if it's hidden, then you want to show it up after html loads..
window.onload = function(){
document.getElementById("mydivid").style.visibility = 'visible';
}
+ 3
There are different ways to do what you're asking for but what I'd recommend is that you create your "div" just the way you'd like it beforehand and then set it's default opacity to 0. You can then control that div's opacity in Javascript and set a delay time for it to load of your choice.
Example (HTML, CSS, Javascript):
//HTML part:
<div id="div1"></div>
//CSS part:
#div1 {
width:50px;
height:50px;
background-color:blue;
opacity:0;
}
//Javascript part:
var time = setInterval(loadDiv,1000);
function loadDiv(){
var d1 = document.getElementById("div1");
d1.style.opacity = 1;
clearInterval(time);
}
-This will load your div after 1 second has passed after loading the page and you can adjust that number of seconds in "setInterval".
0
be more specific please.