Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Windows 10
- 줄바꿈 문자
- Mac
- context
- maVen
- Source
- resource
- lsof
- GIT
- Quartz
- port
- 네트워크
- IntelliJ
- web.xml
- Eclipse
- JavaScript
- profile
- plugin
- vscode
- 단축키
- xargs
- netsh
- bash
- import
- ssh
- Windows
- tomcat
- find
- grep
- VirtualBox
Archives
- Today
- Total
develog
[jquery] 동적으로 append 한 element 에 click 이벤트 주기 본문
아래 코드는
- 원래 있던 element 는 잘 동작함
- append 로 추가한 element 는 동작하지 않음
$(".tag-wrapper .tag").click(function() {
$(this).remove();
});
on 을 사용
- 원래 있던 element 도 잘 동작함
- append 로 추가한 element 잘 동작함
$(".tag-wrapper").on('click', '.tag', function() {
$(this).remove();
});
HTML
<div class="tag-wrapper">
<span class="tag">태그1</span>
<span class="tag">태그2</span>
<span class="tag">태그3</span>
</div>
Comments