การถอดรหัส 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">
ฟังก์ชันเจล (id) {
ส่งคืน document.getElementById (id);
-
window.onload = function () {
//alert(document.getElementByid("Span1").innerhtml
gel ("btn1"). onclick = function () {
การแจ้งเตือน (encodeuri (เจล ("span1"). innerhtml));
-
gel ("btn2"). onclick = function () {
การแจ้งเตือน (decodeuri (เจล ("span1"). innerhtml));
-
-
</script>
</head>
<body>
<span id = "span1"> สามฮีโร่ของคนบ้ากำลังเพิ่มขึ้น! </span>
<อินพุต type = "ปุ่ม" id = "btn1" value = "เข้ารหัส" />>
<อินพุต type = "ปุ่ม" 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;
ฟังก์ชันเจล (id) {
ส่งคืน document.getElementById (id);
-
ฟังก์ชั่น dectime () {
ถ้า (เวลา> 0) {
เวลา--;
เจล ("timespan"). innerhtml = เวลา;
} อื่น {
// ล้างมือชั่วโมง
ClearInterval (ID);
-
-
window.onload = function () {
id = setInterval (dctime, 1,000);
-
</script>
</head>
<body>
<span> นับถอยหลัง <span id = "timespan" style = "สี: สีแดง"> </span> วินาที </span>
</body>
</html>
js ตรวจสอบว่าอินพุตเป็น number.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 = พรอมต์ ("ป้อนค่าที่จะตัดสิน");
//window.alert(i);
ถ้า (! isnan (i)) {
window.alert ("คือหมายเลข");
} อื่น {
window.alert ("ไม่ใช่ตัวเลข");
-
-
-
</script>
</head>
<body>
<อินพุต type = "ปุ่ม" id = "btn1" value = "หมายเลขผู้ตัดสิน" />>
</body>
</html>
JS ได้รับการสร้างและลบ nodes.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">
ฟังก์ชั่นเจล (id) {return document.getElementById (id); -
window.onload = function () {
gel ("btnproadd"). onclick = function () {
// เพิ่มโหนดเด็กภายใต้ Prulist
var linew = document.createElement ("li");
linew.innerhtml = พรอมต์ ("ป้อนจังหวัดที่จะเพิ่ม");
เจล ("prolist"). ภาคผนวก (linew);
// รีบาวน์กิจกรรมคลิกและลบทั้งหมด
dellionclick ();
-
// ดับเบิลคลิกที่โหนดเด็กหลี่และลบออก
ฟังก์ชั่น dellionclick () {
// 1. ก่อนอื่นรับโหนดเด็กทั้งหมด
var linodes = gel ("prolist"). เด็ก;
สำหรับ (var i = 0; i <linodes.length; i ++) {
linodes [i] .onclick = function () {
//alert(linodes [ฉันเหมือนกัน).innerhtml;//because onclick ผูกฟังก์ชันที่ไม่ระบุชื่อฉันจะเป็น 7 ที่นี่เสมอ
// ต่อไปนี้เป็นวิธีที่ถูกต้องในการลบใช้สิ่งนี้ เพราะสิ่งที่กระตุ้นให้เกิดเหตุการณ์ onclick เป็น li ที่คุณเลือกเสมอ
this.parentNode.removeChild (นี่);
-
-
-
-
</script>
</head>
<body>
<ul id = "prolist">
<li> Shanxi </li>
<li> Henan </li>
<li> ปักกิ่ง </li>
</ul>
<อินพุต 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;
ฟังก์ชันเจล (id) {
ส่งคืน document.getElementById (id);
-
ฟังก์ชั่น dectime () {
ถ้า (เวลา> 0) {
เวลา--;
เจล ("timespan"). innerhtml = เวลา;
} อื่น {
// ล้างมือชั่วโมง
ClearInterval (ID);
-
-
window.onload = function () {
id = setInterval (dctime, 1,000);
-
</script>
</head>
<body>
<span> นับถอยหลัง <span id = "timespan" style = "สี: สีแดง"> </span> วินาที </span>
</body>
</html>
js เพิ่ม data table.html แบบไดนามิก
การคัดลอกรหัสมีดังนี้:
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<tite> การเพิ่มข้อมูลตารางไดนามิก </title> แบบไดนามิก
<script type = "text/javascript">
var mailarr = [
{"title": "A C# ปัญหา", "Name": "Zhang San", "Date": "2014-03-21"}
{"title": "ปัญหา JavaScript", "Name": "Li Si", "Date": "2014-03-21"},
{"title": "A C คำถาม", "ชื่อ": "55", "วันที่": "2014-03-21"},
{"title": "คำถาม A C ++", "Name": "Zhao Liu", "Date": "2014-03-21"}
-
window.onload = function () {
var tab = document.getElementById ("tb");
// เพิ่มเมธอด Mailarr Loop Traversal ไปยังตารางใน 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 = "<อินพุต type = 'ช่องทำเครื่องหมาย'/>";
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 = "การล่มสลายของชายแดน: ยุบ;">
<tr>
<th> ลำดับ </th>
<th> ชื่อเรื่อง </th>
<th> ส่งจดหมาย </th>
<th> ส่งเวลา </th>
</tr>
<!-ลูปเพิ่มขึ้น->
</table>
</body>
</html>