تصف هذه المقالة تأثير الساعة الرقمية للعد التنازلي التي تنفذها JS. شاركه للرجوع إليه. طريقة التنفيذ المحددة هي كما يلي:
انسخ الرمز على النحو التالي: <! doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html ؛ charset = utf-8" />
<title> Countdown Clock التي تم تنفيذها بواسطة JavaScript </title>
<style>
الجسم ، div {margin: 0 ؛ padding: 0 ؛}
body {color: #ffff ؛ font: 16px/1.5/5fae/8f6f/96c5/9ed1 ؛}
#countdown {width: 300px ؛ text-align: center ؛ الخلفية:#1A1A1A ؛ الهامش: 10px Auto ؛ Padding: 20px 0 ؛}
إدخال {الحدود: 0 ؛ العرض: 283px ؛ الارتفاع: 50px ؛ المؤشر: مؤشر ؛ الهامش-توب: 20px ؛ الخلفية: url (// www.vevb.com/jscss/demoimg/201210/btn-1.png) no-repeat ؛}
input.cancel {background -position: 0 -50px ؛}
span {color:#000 ؛ width: 80px ؛ line-height: 2 ؛ background: #fbfbfb ؛ الحدود: 2px solid#b4b4b4 ؛ margin: 0 10px ؛ padding: 0 10px ؛}
</style>
<script>
window.onload = function ()
{
var ocountdown = document.getElementById ("العد التنازلي") ؛
var ainput = ocountdown.getElementSbyTagName ("input") [0] ؛
var timer = null ؛
Ainput.onclick = function ()
{
this.classname == ""؟ (Timer = setInterval (updateTime ، 1000) ، updateTime ()): (clearinterval (timer)) ؛
this.className = this.className == ''؟ "يلغي" : ''؛
} ؛
تنسيق الوظيفة (أ)
{
إرجاع A.ToString (). استبدال (/^(/d) $/، '0 $ 1')
}
وظيفة updateTime ()
{
var aspan = ocountdown.getElementSbyTagName ("span") ؛
var oremain = aspan [0] .innerhtml.replace (/^0/، '') * 60 + parseint (aspan [1] .innerhtml.replace (/^0/، '')) ؛
إذا (oremain <= 0)
{
ClearInterval (مؤقت) ؛
يعود
}
أوريمين-؛
aspan [0] .innerhtml = format (parseint (oremain / 60)) ؛
oremain ٪ = 60 ؛
aspan [1] .innerhtml = format (parseint (oremain)) ؛
}
}
</script>
</head>
<body>
<div id = "countdown">
<span> 01 </span> min <span> 40 </span> ثانية
<type type = "button" value = "" />
</viv> wulin.com www.vevb.com رمز المؤثرات الخاصة
</body>
</html>
آمل أن تكون هذه المقالة مفيدة لبرمجة JavaScript للجميع.