javascript - How to make div text fade in -


i using javascript make text inside div fade in on page load. seems work times text shows on page load half second, disappears , fades in it's supposed to. i've tried moving javascript header, above body tag , below /body tag. runs same. thanks.

<body onload="javascript:showdiv('layer63');">  <div id="layer63" class="style1z"> <span class="style16">“line 1 of fade in text"<br /> “line 2 of fade in text"</span><br /> -<span class="style12">“line 3 of fade in text"</span></div>  </body>  <script> function showdiv(name){ //duration of transition (1000 miliseconds equals 1 second) var duration = 1500; // how many times should should changed in delay duration var amountofactions=30;  var diiv= document.getelementbyid(name); diiv.style.opacity = '0';   diiv.style.display = 'block';   var counte=0; setinterval(function(){counte ++;    if ( counte<amountofactions) { diiv.style.opacity = counte/amountofactions;} }, duration / amountofactions); } </script> 

try putting these css attributes:

#layer63 {   opacity: 0;   display: none; } 

since you're animating opacity 0 anyway , set ur display block js why not have them hidden @ pageload?


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -