문제

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

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top