여러개의 이벤트 리스너 한 번에 설정 - on()

여러개의 이벤트 리스너 한 번에 설정 - on()

1. 방법
1) 구문
- on 메소드에 '이벤트명 : 값' 을 이용하여 여러개 셋팅이 가능하다
2) 예

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
<!DOCTYPE html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #outer{
            border : 1px solid black;
            width: 400px;
            height :400px;
        }
    </style>
</head>
<div id="outer"></div>
<script>
    $('#outer').on({
        'mouseenter': function(e) {
            $(this).css('border-color','red');
        },
        'mouseleave':function (e) {
            $(this).css('border-color','black');
        },
        'click':function(e){
            $(this).css('background-color','blue');
        }
    });
</script>