[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);
});
게시판 목록
퀴즈게시판
답을 맞히시면, 문제를 내신 회원님이 채택을 해드립니다.
채택은 '좋아요'와 같습니다.
채택은 '좋아요'와 같습니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 546 | 8년 전 | 1797 | ||
| 545 | 8년 전 | 1999 | ||
| 544 | 8년 전 | 2269 | ||
| 543 | 8년 전 | 1815 | ||
| 542 | 8년 전 | 1932 | ||
| 541 | 8년 전 | 2190 | ||
| 540 | 8년 전 | 2067 | ||
| 539 | 8년 전 | 2571 | ||
| 538 | 8년 전 | 3757 | ||
| 537 | 8년 전 | 1933 | ||
| 536 | 8년 전 | 4262 | ||
| 535 | 8년 전 | 5337 | ||
| 534 | 8년 전 | 2495 | ||
| 533 | 8년 전 | 2544 | ||
| 532 |
|
8년 전 | 2434 | |
| 531 |
|
8년 전 | 2030 | |
| 530 |
|
8년 전 | 2077 | |
| 529 | 8년 전 | 2579 | ||
| 528 | 10년 전 | 5473 | ||
| 527 | 10년 전 | 3980 | ||
| 526 |
|
11년 전 | 8486 | |
| 525 | 11년 전 | 3597 | ||
| 524 | 11년 전 | 4588 | ||
| 523 | 11년 전 | 3471 | ||
| 522 | 11년 전 | 3715 | ||
| 521 | 11년 전 | 5076 | ||
| 520 | 11년 전 | 4359 | ||
| 519 | 11년 전 | 3429 | ||
| 518 | 11년 전 | 4799 | ||
| 517 | 11년 전 | 4462 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기