[jQuery] 재밌는 제이쿼리 3
제이쿼리 이벤트에
.bind(), .live(), .delegate() 대신 .on() 의 사용을 권고하며
.live() .die()는 jQuery 1.9 부터 빠졌습니다.
습관을 on 으로 하면 좋겠지요?
그렇다면 제이쿼리 3 번째 문제 입니다.
아래 점선내용에 on 을 사용 하여 마우스오버, 마우스아웃, 클릭 <-- 이 3가지를 on 에서 처리 되도록 하면 됩니다.
오버시 : 배경색이 red
아웃시 : 배경색이 흰색
클릭시 : 배경색이 노랑색
-----------------------------------
<span id="temp">베타테스터</span>
-----------------------------------
화이팅!!
댓글 2개
11년 전
$('#temp').on({
mouseenter : function() {
$(this).css({'background-color':'red'});
},
mouseleave : function() {
$(this).css({'background-color':''});
},
click : function() {
$(this).css({'background-color':'yellow'});
}
});
mouseenter : function() {
$(this).css({'background-color':'red'});
},
mouseleave : function() {
$(this).css({'background-color':''});
},
click : function() {
$(this).css({'background-color':'yellow'});
}
});
11년 전
추가
$('#temp').on('mouseenter mouseleave click', function(event){
var bgc = '';
var types = event.type;
if(types == 'mouseenter') bgc = 'red';
else if(types == 'mouseleave') bgc = 'white';
else if(types == 'click') bgc = 'yellow';
$(this).css('background-color', bgc);
});
$('#temp').on('mouseenter mouseleave click', function(event){
var bgc = '';
var types = event.type;
if(types == 'mouseenter') bgc = 'red';
else if(types == 'mouseleave') bgc = 'white';
else if(types == 'click') bgc = 'yellow';
$(this).css('background-color', bgc);
});
게시판 목록
퀴즈게시판
답을 맞히시면, 문제를 내신 회원님이 채택을 해드립니다.
채택은 '좋아요'와 같습니다.
채택은 '좋아요'와 같습니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 516 | 11년 전 | 4888 | ||
| 515 | 11년 전 | 4622 | ||
| 514 | 11년 전 | 5301 | ||
| 513 | 11년 전 | 5817 | ||
| 512 | 11년 전 | 3828 | ||
| 511 | 11년 전 | 11702 | ||
| 510 |
|
11년 전 | 4259 | |
| 509 | 11년 전 | 4855 | ||
| 508 | 11년 전 | 3363 | ||
| 507 | 11년 전 | 3120 | ||
| 506 | 11년 전 | 7580 | ||
| 505 | 11년 전 | 5642 | ||
| 504 |
스마트그누
|
11년 전 | 4570 | |
| 503 | 11년 전 | 4458 | ||
| 502 | 11년 전 | 2821 | ||
| 501 | 11년 전 | 2434 | ||
| 500 | 11년 전 | 2917 | ||
| 499 | 11년 전 | 3220 | ||
| 498 | 11년 전 | 2508 | ||
| 497 | 11년 전 | 2176 | ||
| 496 | 11년 전 | 2536 | ||
| 495 | 11년 전 | 2676 | ||
| 494 | 11년 전 | 3007 | ||
| 493 | 11년 전 | 3163 | ||
| 492 | 11년 전 | 3011 | ||
| 491 | 11년 전 | 3089 | ||
| 490 |
스마트그누
|
11년 전 | 3238 | |
| 489 |
스마트그누
|
11년 전 | 4186 | |
| 488 | 11년 전 | 2768 | ||
| 487 | 11년 전 | 2576 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기