JS Décodage et encodage.html
La copie de code est la suivante:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<adal>
<meta http-equiv = "contenu-type" contenu = "text / html; charset = utf-8" />
<Title> Encodage et décodage JavaScript </Title>
<script type = "text / javascript">
fonction gel (id) {
return document.getElementById (id);
}
window.onload = function () {
//alert(Document.getElementByid("span1").innerhtml
gel ("btn1"). onclick = function () {
alerte (encodéuri (gel ("span1"). innerHTML));
};
gel ("btn2"). onclick = function () {
alert (decodeuri (gel ("span1"). innerHTML));
};
};
</cript>
</ head>
<body>
<span id = "span1"> Les trois héros de l'homme fou augmentent! </span>
<input type = "bouton" id = "btn1" value = "codé" />
<input type = "bouton" id = "btn2" value = "décodé" />
</docy>
</html>
Utilisation de SetInterval et Settimeout dans JS.HTML
La copie de code est la suivante:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<adal>
<meta http-equiv = "contenu-type" contenu = "text / html; charset = utf-8" />
<Title> Utilisation de setInterval et setTimeout dans JS </TITME>
<script type = "text / javascript">
Var Time = 10;
var id = 0;
fonction gel (id) {
return document.getElementById (id);
}
fonction dectime () {
if (time> 0) {
temps--;
gel ("timepan"). innerHtml = temps;
} autre {
// efface la main de l'heure
ClearInterval (id);
}
}
window.onload = function () {
id = setInterval (dCtime, 1000);
};
</cript>
</ head>
<body>
<span> compte à rebours <span id = "timepan" style = "couleur: rouge;"> </span> secondes </span>
</docy>
</html>
JS Vérifiez si l'entrée est un nombre.html
La copie de code est la suivante:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<adal>
<meta http-equiv = "contenu-type" contenu = "text / html; charset = utf-8" />
<Title> JS Vérifiez si l'entrée est un nombre </Title>
<script type = "text / javascript">
window.onload = function () {
document.getElementById ("btn1"). onClick = function () {
var i = invite ("Entrez la valeur à juger");
//window.alert(i);
if (! Isnan (i)) {
Window.Alert ("est numéro");
} autre {
Window.Alert ("pas un nombre");
}
};
}
</cript>
</ head>
<body>
<entrée type = "bouton" id = "btn1" value = "juge numéro" />
</docy>
</html>
js obtenir, créer et supprimer dynamiquement nœuds.html
La copie de code est la suivante:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<adal>
<meta http-equiv = "contenu-type" contenu = "text / html; charset = utf-8" />
<Title> js Obtenir, créer et supprimer dynamiquement les nœuds </Title>
<script type = "text / javascript">
fonction gel (id) {return document.getElementById (id); }
window.onload = function () {
gel ("btnproadd"). onclick = function () {
// ajouter des nœuds enfants sous prolist
var linew = document.CreateElement ("li");
linew.innerhtml = invite ("Entrez la province à ajouter");
gel ("prolist"). appenchild (linew);
// Rebondra tous les événements cliqueurs
DellionClick ();
};
// double-cliquez sur le nœud enfant Li et supprimez-le
fonction dellionClick () {
// 1. Obtenez d'abord tous les nœuds enfants
var linodes = gel ("prolist"). ChildNodes;
pour (var i = 0; i <linodes.length; i ++) {
linodes [i] .onclick = function () {
//alert(Linodes@I
// Ce qui suit est la bonne façon de le supprimer, utilisez-le. Parce que celui qui déclenche l'événement onclick est toujours le Li que vous avez sélectionné
this.parentnode.removechild (this);
};
}
}
};
</cript>
</ head>
<body>
<ul id = "prolist">
<li> Shanxi </li>
<li> Henan </li>
<li> Pékin </li>
</ul>
<input type = "Button" value = "Ajouter une nouvelle province" id = "btnproadd" />
</docy>
</html>
Utilisation de SetInterval et Settimeout dans JS.HTML
La copie de code est la suivante:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<adal>
<meta http-equiv = "contenu-type" contenu = "text / html; charset = utf-8" />
<Title> Utilisation de setInterval et setTimeout dans JS </TITME>
<script type = "text / javascript">
Var Time = 10;
var id = 0;
fonction gel (id) {
return document.getElementById (id);
}
fonction dectime () {
if (time> 0) {
temps--;
gel ("timepan"). innerHtml = temps;
} autre {
// efface la main de l'heure
ClearInterval (id);
}
}
window.onload = function () {
id = setInterval (dCtime, 1000);
};
</cript>
</ head>
<body>
<span> compte à rebours <span id = "timepan" style = "couleur: rouge;"> </span> secondes </span>
</docy>
</html>
js ajouter dynamiquement les données de table.html
La copie de code est la suivante:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<adal>
<meta http-equiv = "contenu-type" contenu = "text / html; charset = utf-8" />
<Title> Ajout dynamique des données de table </TITAL>
<script type = "text / javascript">
var mailarr = [
{"Title": "A C # Problem", "Name": "Zhang San", "Date": "2014-03-21"},
{"Title": "A JavaScript Problem", "Name": "Li si", "Date": "2014-03-21"},
{"Title": "A C Question", "Nom": "55", "Date": "2014-03-21"},
{"Title": "A C ++ Question", "Nom": "Zhao Liu", "Date": "2014-03-21"}
]]
window.onload = function () {
var tab = document.getElementById ("TB");
// Ajouter la méthode de traversée de boucle Mailarr à la table dans TR
pour (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.ApendChild (Th1);
Tr.ApendChild (Th2);
Tr.ApendChild (Th3);
Tr.ApendChild (Th4);
TAB.APPENDCHILD (TR);
}
};
</cript>
</ head>
<body>
<table id = "tb" style = "border-collapse: effondrement;">
<tr>
<h> Séquence </th>
<th> Titre </th>
<h> Envoyez Mailer </th>
<h> Envoyez le temps </th>
</tr>
<! - Augmentation de la boucle ->
</ table>
</docy>
</html>