JS فك التشفير والتشفير. html
نسخة الكود كما يلي:
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html ؛ charset = utf-8" />
<title> ترميز JavaScript وفك تشفيره </title>
<script type = "text/javaScript">
وظيفة هلام (معرف) {
return document.getElementById (id) ؛
}
window.onload = function () {
//alert(document.getElementById("span1").innerhtml
هلام ("btn1"). onClick = function () {
تنبيه (encodeuri (هلام ("span1"). innerhtml)) ؛
} ؛
هلام ("btn2"). onClick = function () {
تنبيه (decodeuri (gel ("span1"). innerhtml)) ؛
} ؛
} ؛
</script>
</head>
<body>
<span id = "span1"> الأبطال الثلاثة للرجل المجنون يرتفعون! </span>
<type type = "button" id = "btn1" value = "الترميز" />
<type type = "button" id = "btn2" value = "decoded" />
</body>
</html>
استخدام setInterval و setTimeout في JS.HTML
نسخة الكود كما يلي:
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text/html ؛ charset = utf-8"/>
<title> باستخدام SetInterval و SetTimeout في JS </title>
<script type = "text/javaScript">
var time = 10 ؛
var id = 0 ؛
وظيفة هلام (معرف) {
return document.getElementById (id) ؛
}
وظيفة dectime () {
if (time> 0) {
وقت--؛
هلام ("TimePan"). innerhtml = time ؛
} آخر {
// امسح يد الساعة
ClearInterval (id) ؛
}
}
window.onload = function () {
id = setInterval (dctime ، 1000) ؛
} ؛
</script>
</head>
<body>
<span> العد التنازلي <span id = "timepan" style = "color: red ؛"> </span> Seconds </span>
</body>
</html>
JS تحقق مما إذا كان الإدخال هو رقم. html
نسخة الكود كما يلي:
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text/html ؛ charset = utf-8"/>
<title> JS تحقق مما إذا كان الإدخال عبارة عن رقم </title>
<script type = "text/javaScript">
window.onload = function () {
document.getElementById ("BTN1"). onClick = function () {
var i = proper ("أدخل القيمة المراد الحكم عليها") ؛
//window.alert(I) ؛
if (! isnan (i)) {
Window.Alert ("هو رقم") ؛
} آخر {
Window.Alert ("ليس رقمًا") ؛
}
} ؛
}
</script>
</head>
<body>
<type type = "button" id = "btn1" value = "judge number" />
</body>
</html>
JS الحصول على ديناميكي وإنشاء وحذف العقد. html
نسخة الكود كما يلي:
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html ؛ charset = utf-8" />
<title> الحصول على العقد وإنشاء وحذف العقد </title> بشكل ديناميكي
<script type = "text/javaScript">
وظيفة هلام (id) {return document.getElementById (id) ؛ }
window.onload = function () {
هلام ("btnproadd"). onClick = function () {
// أضف العقد الفرعية تحت البروليست
var linew = document.createElement ("li") ؛
linew.innerhtml = proft ("أدخل المقاطعة المراد إضافتها") ؛
هلام ("بروست"). AppendChild (linew) ؛
// ارتداد جميع أحداث النقر والتغيير
dellionclick () ؛
} ؛
// انقر نقرًا مزدوجًا فوق عقدة Li Child وحذفها
وظيفة dellionclick () {
// 1. احصل أولاً على كل العقد الفرعية
var linodes = gel ("prolist").
لـ (var i = 0 ؛ i <linodes.length ؛ i ++) {
linodes [i] .onclick = function () {
//alert(linodes budapi)
// ما يلي هو الطريقة الصحيحة لحذفه ، استخدم هذا. لأن الحدث الذي يثير حدث Onclick هو دائمًا li الذي حددته
this.parentnode.removechild (هذا) ؛
} ؛
}
}
} ؛
</script>
</head>
<body>
<ul id = "prolist">
<li> Shanxi </li>
<li> هنان </li>
<li> بكين </li>
</ul>
<type type = "button" value = "إضافة مقاطعة جديدة" id = "btnproadd" />
</body>
</html>
استخدام setInterval و setTimeout في JS.HTML
نسخة الكود كما يلي:
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text/html ؛ charset = utf-8"/>
<title> باستخدام SetInterval و SetTimeout في JS </title>
<script type = "text/javaScript">
var time = 10 ؛
var id = 0 ؛
وظيفة هلام (معرف) {
return document.getElementById (id) ؛
}
وظيفة dectime () {
if (time> 0) {
وقت--؛
هلام ("TimePan"). innerhtml = time ؛
} آخر {
// امسح يد الساعة
ClearInterval (id) ؛
}
}
window.onload = function () {
id = setInterval (dctime ، 1000) ؛
} ؛
</script>
</head>
<body>
<span> العد التنازلي <span id = "timepan" style = "color: red ؛"> </span> Seconds </span>
</body>
</html>
JS إضافة بيانات الجدول ديناميكيًا. html
نسخة الكود كما يلي:
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html ؛ charset = utf-8" />
<title> إضافة ديناميكية لبيانات الجدول </title>
<script type = "text/javaScript">
var mailarr = [
{"العنوان": "A C# مشكلة" ، "اسم": "Zhang San" ، "Date": "2014-03-21"} ،
{"title": "A JavaScript Problem" ، "Name": "Li Si" ، "Date": "2014-03-21"} ،
{"العنوان": "A C Question" ، "Name": "55" ، "Date": "2014-03-21"} ،
{"title": "A C ++ Question" ، "Name": "Zhao Liu" ، "Date": "2014-03-21"}
] ؛
window.onload = function () {
var tab = document.getElementById ("tb") ؛
// إضافة طريقة اجتياز حلقة Mailarr إلى الجدول في TR
لـ (var rowindex = 0 ؛ rowindex <mailarr.length ؛ rowindex ++) {
var tr = document.createElement ("tr") ؛
var th1 = document.createElement ("th") ؛
var th2 = document.createElement ("th") ؛
var th3 = document.createElement ("th") ؛
var th4 = document.createElement ("th") ؛
th1.innerhtml = "<input type = 'checkbox'/>" ؛
th2.innerhtml = mailArr [rowindex] .title ؛
th3.innerhtml = mailArr [rowindex] .name ؛
th4.innerhtml = mailArr [rowindex] .date ؛
Tr.AppendChild (Th1) ؛
Tr.AppendChild (Th2) ؛
Tr.AppendChild (Th3) ؛
Tr.AppendChild (Th4) ؛
tab.appendchild (tr) ؛
}
} ؛
</script>
</head>
<body>
<table id = "tb" style = "collapse الحدود: الانهيار ؛">
<tr>
<h> التسلسل </th>
<th> العنوان </th>
<th> أرسل mailer </h>
<th> إرسال الوقت </th>
</r>
<!-زيادة الحلقة->
</table>
</body>
</html>