JS 디코딩 및 인코딩 .html
코드 사본은 다음과 같습니다.
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<헤드>
<meta http-equiv = "content-type"content = "text /html; charset = utf-8" />
<title> JavaScript 인코딩 및 디코딩 </title>
<script type = "text/javaScript">
기능 젤 (ID) {
return document.getElementById (id);
}
Window.onload = function () {
//alert(document.getElementByid("span1").innerhtml
겔 ( "btn1"). OnClick = function () {
경고 (encodeuri (gel ( "span1"). innerhtml));
};
겔 ( "btn2"). OnClick = function () {
경고 (decodeuri (gel ( "span1"). innerhtml));
};
};
</스크립트>
</head>
<body>
<span id = "span1"> 미친 사람의 세 영웅이 떠오르고 있습니다! </span>
<입력 유형 = "버튼"id = "btn1"value = "인코딩" />
<입력 유형 = "버튼"id = "btn2"value = "decoded" />
</body>
</html>
js.html에서 setInterval 및 settimeout 사용
코드 사본은 다음과 같습니다.
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<헤드>
<meta http-equiv = "content-type"content = "text/html; charset = utf-8"/>
<title> js </title>에서 setInterval 및 settimeout을 사용합니다
<script type = "text/javaScript">
var time = 10;
var id = 0;
기능 젤 (ID) {
return document.getElementById (id);
}
함수 dectime () {
if (time> 0) {
시간--;
겔 ( "타임 스팬"). innerhtml = 시간;
} 또 다른 {
// 시간 손을 지 웁니다
ClearInterval (id);
}
}
Window.onload = function () {
id = setInterval (dctime, 1000);
};
</스크립트>
</head>
<body>
<Span> Countdown <Span id = "TimesPan"Style = "Color : Red;"> </span> 초 </span>
</body>
</html>
JS 입력이 숫자인지 확인하십시오. html
코드 사본은 다음과 같습니다.
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<헤드>
<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 = prompt ( "판단 할 값을 입력");
//window.alert(i);
if (! isnan (i)) {
window.alert ( "is number");
} 또 다른 {
window.alert ( "숫자가 아님");
}
};
}
</스크립트>
</head>
<body>
<입력 유형 = "버튼"id = "btn1"value = "판사 번호" />
</body>
</html>
JS는 Nodes.html을 동적으로 얻고 만들고 삭제합니다
코드 사본은 다음과 같습니다.
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<헤드>
<meta http-equiv = "content-type"content = "text /html; charset = utf-8" />
<title> js 노드를 동적으로 얻고 만들고 삭제합니다 </title>
<script type = "text/javaScript">
function gel (id) {return document.getElementById (id); }
Window.onload = function () {
젤 ( "btnproadd"). onclick = function () {
// prolist에서 자식 노드를 추가합니다
var linew = document.createElement ( "li");
linew.innerhtml = prompt ( "추가 할 주를 입력하십시오");
젤 ( "prolist"). AppendChild (linew);
// 모든 클릭 앤 델리트 이벤트를 반등시킵니다
dellionClick ();
};
// LI HILD 노드를 두 번 클릭하고 삭제하십시오
함수 dellionClick () {
// 1. 먼저 모든 어린이 노드를 얻으십시오
var linodes = gel ( "prolist"). childnodes;
for (var i = 0; i <linodes.length; i ++) {
Linodes [i] .onclick = function () {
//alert(linodes=)) .innerhtml ;//because onclick이 익명 함수를 바인드, 나는 항상 7이 될 것입니다.
// 다음은 삭제하는 올바른 방법입니다. Onclick 이벤트를 트리거하는 것은 항상 당신이 선택한 li이기 때문에
this.parentnode.removechild (this);
};
}
}
};
</스크립트>
</head>
<body>
<ul id = "prolist">
<li> Shanxi </li>
<li> Henan </li>
<li> 베이징 </li>
</ul>
<입력 유형 = "버튼"value = "새 지방 추가"id = "btnproadd" />
</body>
</html>
js.html에서 setInterval 및 settimeout 사용
코드 사본은 다음과 같습니다.
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<헤드>
<meta http-equiv = "content-type"content = "text/html; charset = utf-8"/>
<title> js </title>에서 setInterval 및 settimeout을 사용합니다
<script type = "text/javaScript">
var time = 10;
var id = 0;
기능 젤 (ID) {
return document.getElementById (id);
}
함수 dectime () {
if (time> 0) {
시간--;
겔 ( "타임 스팬"). innerhtml = 시간;
} 또 다른 {
// 시간 손을 지 웁니다
ClearInterval (id);
}
}
Window.onload = function () {
id = setInterval (dctime, 1000);
};
</스크립트>
</head>
<body>
<Span> Countdown <Span id = "TimesPan"Style = "Color : Red;"> </span> 초 </span>
</body>
</html>
JS는 Table Data.html을 동적으로 추가합니다
코드 사본은 다음과 같습니다.
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<헤드>
<meta http-equiv = "content-type"content = "text /html; charset = utf-8" />
<title> 테이블 데이터의 동적 추가 </title>
<script type = "text/javaScript">
var mailarr = [
{ "title": "A C# 문제", "이름": "Zhang San", "Date": "2014-03-21"},
{ "title": "javaScript 문제", "이름": "li si", "date": "2014-03-21"},
{ "title": "a c question", "name": "55", "date": "2014-03-21"},
{ "title": "A C ++ 질문", "이름": "Zhao Liu", "Date": "2014-03-21"}
];
Window.onload = function () {
var tab = document.getElementById ( "TB");
// tr의 테이블에 mailarr loop traversal 메소드 추가
for (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);
}
};
</스크립트>
</head>
<body>
<table id = "tb"style = "Border-Collapse : Collapse;">
<tr>
<th> 시퀀스 </th>
<th> 제목 </th>
<th> 메일러 보내기 </th>
<th> 시간 보내기 </th>
</tr>
<!-루프 증가->
</테이블>
</body>
</html>