Why is ele.style.top animated only when it is placed in setTimeout?

style part

.aa{position:absolute;transition:top 2s;}

html part

<div id="ele" class="aa"></div>

js part

var ele=document.getElementById("ele")
ele.onclick=function(){
    ele.style.top=0
//ele.style.top=100+"px"setTimeouttop0100
setTimeout(function(){
    ele.style.top=100+"px"
},0)
}

online preview address
http://jsbin.com/pucedelowa/e.

now there is a doubt, why only put ele.style.top=100+"px" in seTimeout, click on the text will have the animation effect of transition?
are there any other functions that can achieve the same effect as setTimeout?


ele.style.top=0
ele.style.top=100+'px'

because the Synchronize method will not be rendered until the execution of the method is completed, and the final result is 100px, so the asynchronous method can achieve this effect.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eadc21-47f38.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eadc21-47f38.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?