javascript jquery 2

[jQuery] click과 touchend 차이점 및 주의사항

jQuery에서 이벤트를 다룰 때, click과 touchend 이벤트는 비슷해 보이지만, 모바일 환경에서는 큰 차이가 있습니다. 이 글에서는 click과 touchend의 차이점, 주의해야 할 점, 그리고 이를 고려한 예제 코드를 설명하겠습니다.1. click과 touchend의 차이점click 이벤트마우스로 요소를 클릭할 때 발생합니다.모바일에서는 터치(touch) 이벤트가 발생한 후에도 click이 자동으로 실행됩니다.브라우저에 따라 약간의 지연(delay, 약 300ms)이 발생할 수 있습니다.touchend 이벤트모바일 기기에서 화면을 터치한 후 손가락을 뗄 때 발생합니다.click 이벤트보다 빠르게 실행됩니다.데스크톱 환경에서는 touchend가 발생하지 않습니다.2. 주의해야 할 점① 이중 ..

Develop 2025.02.07

[javascript] jquery selector 선택자 like 로 찾기

jqeury 로 셀렉터 선택자에 접근할 때 문자열 존재여부로 찾기태그의 attr 속성값을 유동적으로 생성할 때 활용할 수 있다. ▶ input 의 name 이 'selector' 와 일치하는 요소$("input[name='selector']") ▶ input 의 id 가 'selector' 로 시작하는 요소 (like 'selector%')$("input[id^='selector']") ▶ input 의 name 에 'selector' 가 포함된 요소 (like '%selector%')$("input[name*='selector']") ▶ input 의 id 가 'selector' 로 끝나는 요소 (like '%selector')$("input[id$='selector']")

Develop 2024.09.10