공부/기타

jQuery $()의 의미

바이크패커 2019. 8. 14. 17:20

 2019.08.14

 

 그 동안 생각없이 썼던 jQuery $()

 이제야 어떻게 동작하는지 알게 됨!

 

 풀어서 예를 작성한 코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<script type="text/javascript">
        
    var $ = function(id) {
        this.id = id;
        this.click = function(f){
            f('홍길동');
        }
        return this;
    }
        
    $('#id').click(function(name) {
        alert(this.id + " -- " + name);
    });
            
</script>
 

 

 click을 클릭 이벤트로 생각하면 안됨

 

 

화면