js实现点击一个框的内容,其内容就显示在另一个框中(onchange事件)

时间:2021-06-10 19:52:55

 

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title></title>
 6     <script>
 7         function select(){
 8             var content1=document.getElementById("select");
 9             var content2=document.getElementById("input");
10             content2.value=content1.value;
11 
12         }
13     </script>
14 </head>
15 <body>
16 <select id="select" onchange="select()">
17     <option value="山东" >山东</option>
18     <option value="河北">河北</option>
19     <option value="重庆">重庆</option>
20     <option value="北京">北京</option>
21 </select>
22 <br>
23 <input type="text" id="input">
24 </body>
25 </html>