Home >Web Front-end >JS Tutorial >Summary of common usages of javascript_Basic knowledge

Summary of common usages of javascript_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 16:47:161108browse

js decoding and encoding.html

Copy code The code is as follows:





Javascript encoding and decoding



The Three Mad Men are here!





The use of setInterval and setTimeout in js.html
Copy code The code is as follows:




< ;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
The use of setInterval and setTimeout in js
< ;script type="text/javascript">
var time = 10;
var id = 0;
function gel(id) {
return document.getElementById(id);
}

function dectime() {
if (time > 0) {
time--;
gel("timespan").innerHTML = time;
} else {
//Clear the hour hand
clearInterval(id);
}
}

window.onload = function() {
id = setInterval(dectime, 1000);
};



Countdownseconds



js checks whether the input is a number.html
Copy code The code is as follows:





js checks whether the input is a number







js dynamically obtains, creates and deletes nodes.html
Copy code The code is as follows:





js dynamically obtains, creates and deletes nodes
< script type="text/javascript">
function gel(id) { return document.getElementById(id); }

window.onload = function () {
gel("btnProAdd" ).onclick = function () {
//Add child nodes under proList
var linew = document.createElement("li");
linew.innerHTML = prompt("Enter the province to be added ");
gel("proList").appendChild(linew);
//Rebind all click delete events
DelLiOnClick();
};

/ /Double-click the li child node to delete it

function DelLiOnClick() {
//1. First get all the child nodes
var liNodes = gel("proList").childNodes;

for (var i = 0; i < liNodes.length; i ) {
liNodes[i].onclick = function () {
//alert(liNodes[i]).innerHTML;/ /Because onclick is bound to an anonymous function, so i will always be 7 here
//The following is the correct way to delete, use this. Because the onclick event is always triggered by the li you selected
this. parentNode.removeChild(this);
};
}
}


};




  • Shanxi

  • Henan

  • Beijing






The use of setInterval and setTimeout in js.html

Copy code The code is as follows:





setInterval and setTimeout in js Use



countdownseconds



js dynamically add table data.html
Copy code The code is as follows:





Dynamicly add table data












Sequence Title Sender Sent File time


< /html>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn