Simple Count Down using Java-script - - HTML,CSS
Simple counter in java script
Time Counter
-------------------------------------------
HTML Code:
<div class="counter">
<h4>Time Counter</h4>
<p id="demo"></p></div>
JavaScript Code:
<script type="text/javascript">
var dely=15;
var i = 0, howManyTimes = 16;
function f() {
if(dely>9){document.getElementById("demo").innerHTML=("00:"+dely--);}
else{document.getElementById("demo").innerHTML=("00:0"+dely--);}
i++;
if( i < howManyTimes ){
setTimeout( f, 1000 );
}else{}
}
f();
</script>
CSS Code:
<style>
h4{ padding: 0px;
margin: 0px;
}
p{ padding: 0px;
margin: 0px;
}
.counter{
padding: 10px;
border: 1px solid brown;
width: 7%;
border-radius: 20px;
background-color: #bbc;
}
#demo{
border: 2px solid black;
padding: 10px;
width: 60px;
font-size: 28px;
background-color: #cfadcc;
color: white;font-weight:bold;
border-radius:20px;
padding-bottom: 3px;
padding-top: 3px;
}
</style>
Post a Comment