1, Getelementbyidgetelementbyid, which is obtained by ID, gets an elementfunctionShowpassword () {varPWD = Documnet.getelementbyid (' Password '); //InnerText does not support FirefoxDocumnet.getelementbyid (' content '). innerHtml =Pwd.value;}2, Getelementsbynamegetelementsbyname represents the value obtained by the name of the property, gets the arrayfunctionnametest () {//based on the node's property name, name = user, to find the node, return the array varUsers = document.getelementsbyname (' user '); for(vari=0;i<users.length;i++){ varv =Users[i].value; if(v = = ' us ') {Users[i].value= ' Hello '; } }}3, getElementsByTagName, which is obtained by tag name, gets an arrayfunctiontagtest () {//gets the node based on the tag name, also an array vartags = document.getelementsbytagname (' input '); for(var-= 0;i<tags.length;i++){ varv =Tags[i].value; } //if only one element is still an array object varts = document.getelementsbytagname (' div '); alert (ts.length);}
DOM model and event handling---basic operations