본문 바로가기
Developer/Javascript & jQuery

[jQuery] jquery ready 좀 깔끔하게 쓰자.

by 순수한소년 2022. 7. 25.
728x90
반응형

@

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    <script>
        $(window).on('load'function(){
            title_copy('타이틀);
        });
    </script>
    <script type="text/javascript">
    $(document).ready(function(){
        $(document)
            .on('click','.클래스명'function (e) {
                var linkTarget = $(this).closest('.클래스명');
 
                if (linkTarget.hasClass('on')==true) {
                    $('.클래스명').removeClass('on');
                } else {
                    $('.클래스명').removeClass('on');
                    $(this).closest('.클래스명').addClass('on');
                }
                return false;
        });
    });
    </script>
cs

@

728x90
반응형