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 | 29 | 30 | 31 |
Tags
- 단축키
- IntelliJ
- ssh
- VirtualBox
- 네트워크
- Mac
- grep
- Windows 10
- plugin
- Quartz
- Eclipse
- profile
- GIT
- 줄바꿈 문자
- vscode
- port
- netsh
- maVen
- bash
- xargs
- find
- Source
- Windows
- context
- lsof
- web.xml
- JavaScript
- tomcat
- resource
- import
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