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">
function gel(id){
document.getElementByID(ID)を返します。
}
window.onload = function(){
//alert(document.getElementbyId("span1").innerhtml
gel( "btn1")。onclick = function(){
アラート(encodeuri(gel( "span1")。innerhtml));
};
gel( "btn2")。onclick = function(){
アラート(decodeuri(gel( "span1")。innerhtml));
};
};
</script>
</head>
<body>
<span id = "span1">クレイジーマンの3人のヒーローが上昇している!</span>
<入力型= "ボタン" id = "btn1" value = "encoded" />
<入力型= "ボタン" id = "btn2" value = "decoded" />
</body>
</html>
js.htmlでのsetintervalおよびsetimeoutの使用
コードコピーは次のとおりです。
<!doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<Meta http-equiv = "content-type" content = "text/html; charset = utf-8"/>
<title> setIntervalとjs </title>でsetimeoutを使用しています
<script type = "text/javascript">
var time = 10;
var id = 0;
function gel(id){
document.getElementByID(ID)を返します。
}
関数dectime(){
if(time> 0){
時間 - ;
gel( "timespan")。innerhtml = time;
} それ以外 {
//時間の手をクリアします
ClearInterval(id);
}
}
window.onload = function(){
id = setInterval(dctime、1000);
};
</script>
</head>
<body>
<span> countdown <span id = "timespan" style = "color:red;"> </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 = prompt( "判断する値を入力する");
//window.alert(i);
if(!isnan(i)){
window.alert( "is number");
} それ以外 {
window.alert( "not a number");
}
};
}
</script>
</head>
<body>
<input type = "button" 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動的にNODESを取得、作成、削除</title>
<script type = "text/javascript">
function gel(id){return document.getElementById(ID); }
window.onload = function(){
gel( "btnproadd")。onclick = function(){
// ProListの下で子ノードを追加します
var linew = document.createelement( "li");
linew.innerhtml = prompt( "追加する州に入る");
gel( "prolist")。appendchild(linew);
//すべてのクリックアンドデレートイベントをリバウンドします
dellionclick();
};
// liチャイルドノードをダブルクリックして削除します
関数dellionclick(){
// 1。最初にすべての子ノードを取得します
var linodes = gel( "prolist")。チャイルドノード;
for(var i = 0; i <linodes.length; i ++){
リノード[i] .onclick = function(){
//alert(linodes [i]).innerhtml;////becase onclickは匿名関数にバインドします、私はいつもここで7になります
//次のことは、それを削除する正しい方法です。これを使用してください。オンクリックイベントをトリガーするものは常にあなたが選択したliだからです
this.parentnode.removechild(this);
};
}
}
};
</script>
</head>
<body>
<ul id = "prolist">
<li> shanxi </li>
<li> enan </li>
<li>北京</li>
</ul>
<入力型= "ボタン"値= "新しいstabince" id = "btnproadd" />
</body>
</html>
js.htmlでのsetintervalおよびsetimeoutの使用
コードコピーは次のとおりです。
<!doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<Meta http-equiv = "content-type" content = "text/html; charset = utf-8"/>
<title> setIntervalとjs </title>でsetimeoutを使用しています
<script type = "text/javascript">
var time = 10;
var id = 0;
function gel(id){
document.getElementByID(ID)を返します。
}
関数dectime(){
if(time> 0){
時間 - ;
gel( "timespan")。innerhtml = time;
} それ以外 {
//時間の手をクリアします
ClearInterval(id);
}
}
window.onload = function(){
id = setInterval(dctime、1000);
};
</script>
</head>
<body>
<span> countdown <span id = "timespan" style = "color:red;"> </span>秒</span>
</body>
</html>
jsはテーブルdata.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 = [
{"title": "a c#upblem"、 "name": "Zhang San"、 "date": "2014-03-21"}、
{"title": "a javascriptの問題"、 "name": "li si"、 "date": "2014-03-21"}、
{"title": "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");
// TRのテーブルにMailARRループトラバーサル法を追加する
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 = "<入力型= 'チェックボックス'/>";
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>
<表ID = "TB" style = "border-collapse:collapse;">
<tr>
<th>シーケンス</th>
<th>タイトル</th>
<th>メーラーを送信</th>
<th>時間を送信</th>
</tr>
<! - ループの増加 - >
</table>
</body>
</html>