juery 학습 총결산--예

2860 단어
1. select 요소는 선택한 값과option의 값을 찾습니다.
 1 <!DOCTYPE html>
 2 <html>
 3 <head lang="en">
 4     <meta charset="UTF-8">
 5     <title></title>
 6     <script type="text/javascript" src="jquery-1.11.2.js"></script>
 7     <script type="text/javascript">
 8         $(function(){
 9                     $("select").change(function () {
10                         $("span").eq(0).html($(this).val())
11                         $("span").eq(1).html($(this).find("option:selected").text())
12                      })
13             $("span").eq(0).html($("select").val())
14             $("span").eq(1).html($("select").find("option:selected").text())
15         })
16 
17     </script>
18 </head>
19 <body>
20  :<select>
21     <option value = "1">hello</option>
22     <option value = "2">world</option>
23     <option value = "3">change</option>
24     <option value = "4">le</option>
25 </select>
26 <div> :<span ></span>;value :<span></span></div>
27 </body>
28 </html>

좋은 웹페이지 즐겨찾기