<!doctype html><html><head><meta charset="utf-8"><title>無標(biāo)題文檔</title><style>#cb{ width:1200px; height:20px; border:3px solid rgba(0,204,255,1);? ? ?border-radius:10px; background-image:url(1.jpg) }</style></head><body><input type="button" value="展開" onClick="aa()" id="cn"><div id="cb"></div><script>?var cn=document.getElementById("cn");?var ?h=0;function a(){ if(h<720) { h=h+10; document.getElementById("cb").style.height=h+"px"; cn.value="收起"; } else{ return } setTimeout(a,10);} function b(){ if(h>20){ h=h-20; document.getElementById("cb").style.height=h+"px"; cn.value="展開"; } else{ return } setTimeout(a,10) }/**/function aa(){ //t=setInterval(time,50); a(); b(); } </script></body></html>
一個按鈕控制一個div的展開收起,需要用定時器,不知道下面的代碼錯在哪里
Echo_Chien
2016-08-02 09:00:17