테스트 사이트 - 개발 중인 베타 버전입니다

if문 focus들어갓을때 나왔을떄 채택완료

그누보드초보이용자 6년 전 조회 3,918

if $("[type=text]").focus(function() { 

        $(this).prev().animate({opacity:1}, 700);         $(this).attr('placeholder', ' ');         $(this).css('border-bottom', '2px solid #0e7bfc');

    } else {

    } });

 

 

포커스가가면 저위에 스타일이먹고 나오면 원상복구 되는 걸하고싶은데..

우선 이프문 부터 안먹히는데 방법좀알려주세요..

댓글을 작성하려면 로그인이 필요합니다.

답변 3개

채택된 답변
+20 포인트
프라푸치노K

$('[type=text]').on('focus',function(){  $(this).prev().animate({opacity:1}, 700);  $(this).attr('placeholder', ' ');  $(this).css('border-bottom', '2px solid #0e7bfc');  }).on('focusout',function(){

 

$(this).prev().animate({opacity:0}, 200);  $(this).attr('placeholder');  $(this).css('border-bottom', '1px solid #b2b2b2'); 

 

}) ; 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

6년 전

$('[type=text]').on('focusin',function(){ //포커스 인

 

 

});

 

$('[type=text]').on('focusout',function(){ //포커스 아웃

 

 

});

 

안에 각 상태일때 원하시는 작업을 넣으시면 될거 같습니다.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

그누보드초보이용자
6년 전
이프분으로 제어가능한방법은 없을까요?

댓글을 작성하려면 로그인이 필요합니다.

프라푸치노K

$('[type=text]').on('focus',function(){

 

 

});

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

그누보드초보이용자
6년 전
$('[type=text]').on('focus',function(){
if($(this).focus){
$(this).prev().animate({opacity:1}, 700);
$(this).attr('placeholder', ' ');
$(this).css('border-bottom', '2px solid #0e7bfc');
}else{
$(this).prev().animate({opacity:0}, 200);
$(this).attr('placeholder');
$(this).css('border-bottom', '1px solid #b2b2b2');
}
});


이러면 포커스가 빠졋을때는 반응이 없습니다..

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인