1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE HTML>
<html lang="ko">
<head>
    <meta charset="utf-8">
    <script src="js/jquery.js"></script>
</head>
<body>
    <select>
        <option>테스트1</option>
        <option>테스트2</option>
        <option selected="selected">테스트3</option>
        <option>테스트4</option>
        <option>테스트5</option>
        <option>테스트6</option>
    </select>
    <script>
    
        $("select").change(function() {  
            
            //var test = this.selectedOptions[0].getAttribute("selected"); 
            //console.log(test);
            
            var selected = $(this).find('option:selected');
            
            console.log(selected.text());
            
            
        }).change();
          
    </script>
</body>
</html>


반응형
Posted by 힘없는염소