JS decodificación y codificación.html
La copia del código es la siguiente:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<Evista>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> JavaScript Codificación y decodificación </title>
<script type = "text/javaScript">
function gel (id) {
return document.getElementById (id);
}
window.onload = function () {
//alert(Document.getElementByid("Span1").innerhtml
gel ("btn1"). onClick = function () {
alerta (encodeuri (gel ("span1"). innerhtml));
};
gel ("btn2"). onClick = function () {
alerta (decodeuri (gel ("span1"). innerhtml));
};
};
</script>
</ablo>
<Body>
<span id = "span1"> Los tres héroes de The Crazy Man están aumentando! </span>
<input type = "button" id = "btn1" value = "encoded" />
<input type = "button" id = "btn2" value = "decoded" />
</body>
</html>
Uso de SetInterval y SetTimeout en JS.HTML
La copia del código es la siguiente:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<Evista>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8"/>
<title> Uso de SetInterval y SetTimeout en JS </title>
<script type = "text/javaScript">
tiempo var = 10;
var id = 0;
function gel (id) {
return document.getElementById (id);
}
función dectime () {
if (tiempo> 0) {
tiempo--;
gel ("Timespan"). Innerhtml = Time;
} demás {
// despejar la mano de la hora
ClearInterval (id);
}
}
window.onload = function () {
id = setInterval (dcTime, 1000);
};
</script>
</ablo>
<Body>
<span> Countdown <span id = "Timespan" style = "color: rojo;"> </span> segundos </span>
</body>
</html>
JS verifique si la entrada es un número.html
La copia del código es la siguiente:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<Evista>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8"/>
<title> js verifique si la entrada es un número </title>
<script type = "text/javaScript">
window.onload = function () {
document.getElementById ("btn1"). onClick = function () {
var i = inder ("Ingrese el valor a juzgar");
//window.alert(i);
if (! isnan (i)) {
Window.alert ("es número");
} demás {
Window.alert ("no un número");
}
};
}
</script>
</ablo>
<Body>
<input type = "button" id = "btn1" valor = "número de juez" />
</body>
</html>
JS obtiene, crea y elimina los nodos.html
La copia del código es la siguiente:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<Evista>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> JS obtiene, crea y elimina los nodos </title>
<script type = "text/javaScript">
function gel (id) {return document.getElementById (id); }
window.onload = function () {
gel ("btnproadd"). onClick = function () {
// Agregar nodos infantiles
var linew = document.createElement ("li");
linew.innerhtml = inder ("Ingrese la provincia a agregar");
gel ("prolist"). appendchild (linew);
// rebota en todos los eventos de clic y eliminación
DellionClick ();
};
// Haga doble clic en el nodo infantil LI y elimínelo
function dellionClick () {
// 1. Primero consigue todos los nodos infantiles
var linodes = gel ("prolist"). Nodos infantiles;
para (var i = 0; i <linodes.length; i ++) {
Linodes [i] .Onclick = function () {
//alert(linodes[ifont>)
// La siguiente es la forma correcta de eliminarlo, use esto. Porque el que desencadena el evento OnClick es siempre el LI que seleccionó
this.parentnode.removechild (this);
};
}
}
};
</script>
</ablo>
<Body>
<ul id = "prolist">
<li> shanxi </li>
<li> Henan </li>
<li> Beijing </li>
</ul>
<input type = "button" value = "Agregar nueva provincia" id = "btnproadd" />
</body>
</html>
Uso de SetInterval y SetTimeout en JS.HTML
La copia del código es la siguiente:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<Evista>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8"/>
<title> Uso de SetInterval y SetTimeout en JS </title>
<script type = "text/javaScript">
tiempo var = 10;
var id = 0;
function gel (id) {
return document.getElementById (id);
}
función dectime () {
if (tiempo> 0) {
tiempo--;
gel ("Timespan"). Innerhtml = Time;
} demás {
// despejar la mano de la hora
ClearInterval (id);
}
}
window.onload = function () {
id = setInterval (dcTime, 1000);
};
</script>
</ablo>
<Body>
<span> Countdown <span id = "Timespan" style = "color: rojo;"> </span> segundos </span>
</body>
</html>
JS Agregar dinámicamente datos de tabla.html
La copia del código es la siguiente:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<Evista>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> Adición dinámica de datos de tabla </title>
<script type = "text/javaScript">
var mailarr = [
{"Título": "A C# Problema", "Nombre": "Zhang San", "Fecha": "2014-03-21"},
{"Título": "Un problema de JavaScript", "Nombre": "Li si", "fecha": "2014-03-21"},
{"Título": "A C Pregunta", "Nombre": "55", "Fecha": "2014-03-21"},
{"Título": "A C ++ pregunta", "Nombre": "Zhao Liu", "Fecha": "2014-03-21"}
];
window.onload = function () {
var tab = document.getElementById ("tb");
// Agregar el método de transversal de bucle Mailarr a la tabla en TR
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);
}
};
</script>
</ablo>
<Body>
<table id = "tb" style = "border-colapse: colapso;">
<tr>
<th> secuencia </th>
<th> Título </th>
<th> Enviar Mailer </th>
<th> Enviar tiempo </th>
</tr>
<!-aumento de bucle->
</table>
</body>
</html>