0

How can I Display div with JavaScript !!

I wanna display a div from right after page finish loading !!

17th Apr 2017, 9:59 PM
Shimaa Khaled
Shimaa Khaled - avatar
4 Respuestas
+ 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 ^_^
17th Apr 2017, 10:21 PM
Maz
Maz - avatar
+ 3
if it's hidden, then you want to show it up after html loads.. window.onload = function(){ document.getElementById("mydivid").style.visibility = 'visible'; }
17th Apr 2017, 10:08 PM
Welliton Malta
Welliton Malta - avatar
+ 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".
17th Apr 2017, 10:17 PM
Ghauth Christians
Ghauth Christians - avatar
0
be more specific please.
17th Apr 2017, 10:06 PM
Giannis Tsirovasilis
Giannis Tsirovasilis - avatar