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

时间:2023-02-11 22:34:22

 

 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>