IT

자바 펼쳐가 입력에 점점이 맞는지 감지

lottoking 2020. 8. 9. 09:17
반응형

자바 펼쳐가 입력에 점점이 맞는지 감지 [중복]


이 질문에 이미 답변이 있습니다.

.click텍스트 영역이 이미 포커스 된 경우 이벤트가 트리거되는 시기를 어떻게 감지?

이 jquery가 있습니다.

$(".status").on("click","textarea",function(){
        if ($(this) == "focused") {
            // fire this step
        }else{
            $(this).focus();
            // fire this step
    }

순수 자바 펼쳐 사용 :

this === document.activeElement // where 'this' is a dom object

또는 jquery의 :focus의사 선택기로.

$(this).is(':focus');


jQuery의 .is ( ": focus") 사용

$(".status").on("click","textarea",function(){
        if ($(this).is( ":focus" )) {
            // fire this step
        }else{
                    $(this).focus();
            // fire this step
    }

시도해 실험 니 :

$(this).is(':focus');

한 번 봐 가지고 입력 포커스가있는 경우 시험에 jQuery를 사용 하여이 좀 더 많은 예제를 제공합니다


JQuery를 사용할 수있는 권한있습니다. JQuery : 포커스 선택기 를 사용 하면 필요한 작업을 수행 할 수 있습니다.

$(this).is(':focus');

참고 URL : https://stackoverflow.com/questions/17614844/javascript-detect-if-input-is-focused

반응형