check box

JS 2014. 5. 21. 16:04

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
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html>
    <head>
        <title>hello</title>
        <script src='./js/jquery-1.11.1.js'></script>
        <script src='./js/ch15.js'></script>
        <style>
    
        </style>
        <script>
            $(document).ready(function() {
                $('#all-check').change(function(){
                        if(this.checked){
                            $('#check-item').children().prop('checked',true);
                        }else{
                            $('#check-item').children().prop('checked',false);
                        }
                });
                    
            }); //ready
            
            
    
        
        </script>
    </head>
    <body>
        <input type='checkbox' id='all-check' />
        <label>All</label>
        <div id='check-item'>
            <input type='checkbox' />
            <label>A option</label>
            <input type='checkbox'/>
            <label>B option</label>
            <input type='checkbox'/>
            <label>C option</label>
        </div>
    </body>
</html>
 


설정

트랙백

댓글