[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년 전 | 4897 | ||
| 515 | 11년 전 | 4627 | ||
| 514 | 11년 전 | 5305 | ||
| 513 | 11년 전 | 5819 | ||
| 512 | 11년 전 | 3833 | ||
| 511 | 11년 전 | 11705 | ||
| 510 |
|
11년 전 | 4261 | |
| 509 | 11년 전 | 4863 | ||
| 508 | 11년 전 | 3367 | ||
| 507 | 11년 전 | 3125 | ||
| 506 | 11년 전 | 7585 | ||
| 505 | 11년 전 | 5645 | ||
| 504 |
스마트그누
|
11년 전 | 4573 | |
| 503 | 11년 전 | 4468 | ||
| 502 | 11년 전 | 2825 | ||
| 501 | 11년 전 | 2437 | ||
| 500 | 11년 전 | 2919 | ||
| 499 | 11년 전 | 3225 | ||
| 498 | 11년 전 | 2512 | ||
| 497 | 11년 전 | 2187 | ||
| 496 | 11년 전 | 2542 | ||
| 495 | 11년 전 | 2678 | ||
| 494 | 11년 전 | 3010 | ||
| 493 | 11년 전 | 3167 | ||
| 492 | 11년 전 | 3013 | ||
| 491 | 11년 전 | 3092 | ||
| 490 |
스마트그누
|
11년 전 | 3242 | |
| 489 |
스마트그누
|
11년 전 | 4190 | |
| 488 | 11년 전 | 2772 | ||
| 487 | 11년 전 | 2579 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기