1. 程式人生 > >JS學習筆記 - 微博釋出效果

JS學習筆記 - 微博釋出效果

 

 

<script>
    window.onload = function()
    {
        var oTxt = document.getElementById('txt1');
        var oBtn = document.getElementById('btn1');
        var oUl = document.getElementById('ul1');

        oBtn.onclick = function()
        {
            // var aLi = oUl.getElementsByTagName('li');
// 補寫: var oLi=document.createElement('li'); // 先建立元素,再在後面用appendChild加給oUl // 賦值寫反了! oTxt.innerHTML = oLi.value; // 前面用的是aLi,這裡怎麼表示單個li的值 oLi.innerHTML=oTxt.value; oTxt.value=''; // if(aLi.length>0) if(oUl.children.length
>0) { // oUl.insertBefore(li, aLi[0]) oUl.insertBefore(oLi, oUl.children[0]); } else { // oUl.appendChild('li'); oUl.appendChild(oLi); } var iHeight = oLi.offsetHeight; oLi.style.height
='0'; // ??? startMove(oLi, {height: iHeight}, function (){ startMove(oLi, {opacity: 100}); // 呼叫的框架屬性值用的json格式,所以這裡要用花括號寫。 }); // startMove(oLi, "height", iHeight, function() // { // startMove(oLi, "opacity", 100) // },30); // 運動框架後面括號沒有時間,定時器才有。 }; }; </script>