반응형
입력에 초점이 맞추어져 있는지 확인하는 Javascript/jQuery
다음 시간을 감지하려면 어떻게 해야 합니까?.click
텍스트 영역이 이미 포커스된 경우 이벤트 트리거?
나는 다음과 같은 질문을 받고 있습니다.
$(".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's로:focus
의사선택기
$(this).is(':focus');
JQuery를 사용할 수 있는 경우 JQuery:Focus Selector를 사용하면 필요한 작업을 수행할 수 있습니다.
$(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를 사용하여 입력에 포커스가 있는지 여부를 테스트합니다. 몇 가지 예제가 더 있습니다.
언급URL : https://stackoverflow.com/questions/17614844/javascript-jquery-detect-if-input-is-focused
반응형
'programing' 카테고리의 다른 글
SpringBoot을 사용하여 개발된 REST API에서 Java Object에 매핑할 때 JSON payload 필드를 대소문자 구분 없이 만듭니다. (0) | 2023.10.09 |
---|---|
LOAD DATA LOCAL INFILE 완료를 기다리는 방법 - Java (0) | 2023.10.09 |
ServletContext 리소스 [/WEB-INF/applicationContext.xml]을(를) 열 수 없습니다. (0) | 2023.10.09 |
Pandas에서 공식의 식을 동적으로 평가 (0) | 2023.10.09 |
프로그래밍 방식으로 iPhone의 탈옥 여부 확인 (0) | 2023.10.09 |