JS中for循序中延遲加載動(dòng)態(tài)效果的具體實(shí)現(xiàn)
<script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
for(var i=1; i<6;i++)
{
var a=$("#zhong"+i+"").height(); //獲取高度
$("#zhong"+i+"").attr("OldHeight",a); //設(shè)置OldHeight屬性
}
var e=0; //定義一個(gè)值
interid=setInterval(Showgao,30); //setInerval 每隔30ms加載一次
function Showgao()
{
e++;
for(var x=1;x<6;x++)
{
var b= $("#zhong"+x+"").attr("OldHeight");
if(typeof(b) == "undefined"||b!="")
{
if(e>b){$("#zhong"+x+"").height(b);}
else{$("#zhong"+x+"").height(e);}
}
}
if(e==1000){clearInterval(interid);}
}
});
</script>
再看看HTML代碼
<div class="zhu no1">
<div class="tou"><img src="images/toubg.png" /></div>
<div id="zhong1" class="zhong" style="height:66px;"></div>
<div class="wei"><img src="images/weibg.png" /></div>
</div>
<div class="zhu no2">
<div class="tou"><img src="images/toubg.png" /></div>
<div id="zhong2" class="zhong" style="height:0px;"></div>
<div class="wei"><img src="images/weibg.png" /></div>
</div>
<div class="zhu no3">
<div class="tou"><img src="images/toubg.png" /></div>
<div id="zhong3" class="zhong" style="height:22px;"></div>
<div class="wei"><img src="images/weibg.png" /></div>
</div>
<div class="zhu no4">
<img src="images/huisebg.png" />
</div>
實(shí)現(xiàn)的效果是這樣的,我的意思不知道大家能不能明白,其實(shí)就是先定好這個(gè)圓柱的高度,然后用JS動(dòng)態(tài)的從0往上升,最好達(dá)到設(shè)定好的高度
相關(guān)文章
基于JavaScript 下namespace 功能的簡(jiǎn)單分析
前些天在剝離 百度隨心聽 的播放器引擎時(shí),看到了一個(gè)namespace方法,覺得新奇,當(dāng)然只是對(duì)于我自己而言,我入門js不久,經(jīng)驗(yàn)尚淺2013-07-07JavaScript中Cookies的相關(guān)使用教程
這篇文章主要介紹了JavaScript中Cookies的相關(guān)使用教程,包括Cookies的存儲(chǔ)和刪除等操作方法,需要的朋友可以參考下2015-06-06JavaScript模版引擎的基本實(shí)現(xiàn)方法淺析
這篇文章主要介紹了JavaScript模版引擎的基本實(shí)現(xiàn)方法,講解利用function對(duì)象來一步步編寫簡(jiǎn)單的模板,需要的朋友可以參考下2016-02-02JavaScript fontcolor方法入門實(shí)例(按照指定的顏色來顯示字符串)
這篇文章主要介紹了JavaScript fontcolor方法入門實(shí)例,fontcolor方法用于按照指定的顏色來顯示字符串,需要的朋友可以參考下2014-10-10javascript運(yùn)行機(jī)制之this詳細(xì)介紹
這篇文章主要介紹了javascript運(yùn)行機(jī)制之this,需要的朋友可以參考下2014-02-02javascript真的不難-回顧一下基礎(chǔ)知識(shí)
先來學(xué)習(xí)一下Javascript語言中的基礎(chǔ)知識(shí)問題其時(shí)對(duì)于每種編程語言來說基礎(chǔ)知識(shí)都是大同小異的,對(duì)變量,函數(shù),條件語句塊,循環(huán)語句塊等等,本文簡(jiǎn)要介紹一下,感興趣的朋友可以了解下2013-01-01