js實現(xiàn)正方形顏色從下往上升的效果
更新時間:2014年08月04日 10:16:15 投稿:whsnow
大家有沒有看到類似顏色從下往上升的效果,在本例將與大家介紹下此效果的具體實現(xiàn)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無標題文檔</title> </head> <script src="jquery-1.8.2.js" type="text/javascript"></script> <script type="text/javascript"> $(function(){ interid=setInterval(Showgao,1); var i=1; $('#top').height(8); $('#buttom').css('marginTop',42); $('#buttom').css('background','#d6d6d6'); function Showgao() { var oldH=$('#buttom').css('marginTop'); var h= oldH.substr(0,oldH.indexOf('px')); $('#buttom').css('marginTop',h-1); $('#buttom').height(i); i++; if(i==42){clearInterval(interid);} } interid1=setInterval(Showgao1,1); var i1=1; $('#top1').height(4); $('#buttom1').css('marginTop',46); $('#buttom1').css('background','red'); function Showgao1() { var oldH=$('#buttom1').css('marginTop'); var h= oldH.substr(0,oldH.indexOf('px')); $('#buttom1').css('marginTop',h-1); $('#buttom1').height(i1); i1++; if(i1==30){clearInterval(interid1);} } }); </script> <body> <style> .container{width:20px;height:50px;border:1px solid #999;font-size:10px;float:left;margin-left:5px;} </style> <div class="container" onclick="javascript:alert(1);" > <div id="top">82%</div> <div id="buttom"></div> </div> <div class="container" onclick="javascript:alert(1);" > <div id="top1" >62%</div> <div id="buttom1"></div> </div> </body> </html>
相關(guān)文章
JavaScript中判斷頁面關(guān)閉、頁面刷新的實現(xiàn)代碼
這篇文章主要介紹了JavaScript中判斷頁面關(guān)閉、頁面刷新的實現(xiàn)代碼,在一些特殊的場合中會用到這個技術(shù),需要的朋友可以參考下2014-08-08快速獲取/設(shè)置iframe內(nèi)對象元素的幾種js實現(xiàn)方法
下面小編就為大家?guī)硪黄焖佾@取/設(shè)置iframe內(nèi)對象元素的幾種js實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-05-05bootstrap treeview 擴展addNode方法動態(tài)添加子節(jié)點的方法
bootstrap-treeview 是一款基于Jquery+bootstrap的樹控件,這篇文章主要介紹了bootstrap treeview 擴展addNode方法動態(tài)添加子節(jié)點的方法,需要的朋友可以參考下2017-11-11微信小程序?qū)崿F(xiàn)計時器開始和結(jié)束功能
這篇文章主要為大家詳細介紹了微信小程序?qū)崿F(xiàn)計時器開始和結(jié)束功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-07-07javascript實現(xiàn)禁止右鍵和F12查看源代碼
這篇文章主要介紹了javascript實現(xiàn)禁止右鍵和F12查看源代碼的代碼,需要的朋友可以參考下2014-12-12