실전 코딩/javascript · jquery
[jquery] 이벤트 여러개 설정하기
정리무새
2021. 6. 29. 10:02
728x90
반응형
$('input').on({
focus : function() {
$(this).closest('div').addClass("step01");
if($(this).val() == "") {
$(this).closest('div').removeClass(step02");
}
},
change : function() {
$(this).closest('div').addClass("step02")
if($(this).val() == "") {
$(this).closest('div').removeClass("step01")
$(this).closest('div').removeClass("step02")
}
},
blur : function() {
if($(this).val() == "") {
$(this).closest('div').removeClass("step01")
}
}
});
input이 여러개일때 한번에 focus, change, blur 될때의 이벤트를 처리하고 싶을때 사용했다.
$('대상 컨텐츠').on({
focus : function() {},
change : function() {},
blur : function() {}
});
728x90
반응형