Vra

I have the following code:

<div id='icro' style="position:relative;left:-133px;float: left;top:-60px;opacity:0;">icro</div>
<script>
  var showicroDelay;
  showicro();
  function showicro() {
    document.getElementById('icro').style.opacity=parseInt(document.getElementById('icro').style.opacity) +.05;
    showicroDelay=setTimeout(showicro, 1);
    if (document.getElementById('icro').style.opacity==1) {
      clearTimeout(showicroDelay);
    }
  }
</script>

Can someone spot my mistake? I used basically the same code for moving an element and it worked flawlessly! As of now, it only does it once, as in the opacity gets set to 0.05.

Thanks

Was dit nuttig?

Oplossing

You are using parseInt when you should be using parseFloat since opacity values are between 0 and 1.

Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top