본문 바로가기

JavaScript21

[jQuery] 동적으로 생성된 요소에 이벤트 바인딩 $(staticAncestors).on(eventName, dynamicChild, function() {}); staticAncestors는 범위를 의미하고 eventName은 적용할 이벤트 dynamicChild는 동적으로 생성된 요소입니다. (문서 안에서 remove-btn 이라는 클래스를 가진 요소를 클릭했을때) $(document).on('click', '.remove-btn', function () { ... }); ref : https://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements 2023. 5. 29.
[JavaScript] Feather Icon 동적으로 생성하기 $('ul.list-group').append(``); // 동적 element 생성 feather.replace(); // 아이콘 변환 ref : https://github.com/feathericons/feather/issues/758 2023. 3. 13.
[JavaScript] 즉시 실행 함수 (IIFE) 사용법 즉시 실행 함수 표현(IIFE, Immediately Invoked Function Expression) (function () { statements })(); 함수를 ()로 감싸고 ()을 한번 더 입력하면 사용할 수 있습니다. ref : https://developer.mozilla.org/ko/docs/Glossary/IIFE 2023. 2. 28.
[jQuery] select 드롭다운 비활성화 시키기 $('form').bind('submit', function () { $(this).find(':input').prop('disabled', false); }); 태그에 readonly 속성만 주면 드롭다운은 아직 동작 가능한 상태이다. 이런경우 disabled 속성을 통해 선택을 하지 못하게하고, 폼을 제출할때 해당 속성을 풀어주면 된다. ref : https://stackoverflow.com/questions/1191113/how-to-ensure-a-select-form-field-is-submitted-when-it-is-disabled 2022. 7. 18.