1<!doctype html>234<!--statement current page encoding set (Chinese code "gbk,gb2312", International Code "UTF-8")--5<meta http-equiv= "Content-type" content= "text/html"; charset= "Utf-8" >6 7<title>html Templates </title>8<meta name= "keywords" content= "keywords, key words" >9<meta name= "description" content= "" >Ten<style type= "Text/css" > One*{margin:10 auto;padding:0} A</style> -<script type= "Text/javascript" src= "Jquery-1.11.3.min.js" ></script> -<script type= "Text/javascript" > the varci1=[' Province 1 ', ' Province 2 ', ' Province 3 ', ' Province 4 ']; -Window.onload=function(){ - createCity1 (); - } + functioncreateCity1 () { - varCity1=document.getelementbyid (' City1 '); + //Create label, create label must be parameter must be label name A varOp=document.createelement ("option"); atOp.innerhtml= "Please select Province" - city1.appendchild (OP); - //city1.appendchild ("<option> Please select Province </option>"); it's wrong to write. - - for(vari=0;i<ci1.length;i++){ - //for (var i in CIL) {//With this may appear browser incompatible in varOp_in=document.createelement ("option"); -Op_in.innerhtml=Ci1[i]; to city1.appendchild (op_in) + } - } the$(function(){ * //This shows the power of jquery, the Append method is to add content directly behind the object, and then make the Yi. This is a cow. $$ ("#city2"). Append ("<option> Please select Province </option>");Panax Notoginseng for(vari=0;i<ci1.length;i++){ -$ ("#city2"). Append ("<option>" +ci1[i]+ "</option>"); the } + }) A //createCity1 (); the</script> + -<body> $<select id= "City1" ></select> $<select id= "City2" ></select> - - the</body> - Wuyi
Compare AppendChild () in JavaScript with append () in jquery to know what Jqery is.