<div>
<div></div>
</div>
div안에 있는 div가 제거될시 이벤트가 발생되게 하고 싶은데..
이런 이벤트가 있나요?
댓글 3개
letsgolee
13년 전
오브젝트가 destroy될 때 이벤트 발생관련하는게 원래 자바스크립트에는 없습니다. 다만 setTimeout을 이용해서 만들 수는 있습니다. 다행히 jQuery에 destroyed라는 event를 추가해주는 플러그인을 만든 사람이 있네요. 이걸 이용하면 쉽게 짤 수 있습니다. 예제소스를 만들어보았으니 테스트해보면 쉽게 알수 있어요. 원리도 간단합니다. 단순하게 bind로 destroyed event 추가만 해주면 되요.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> Test for jQuery event.destroyed </title>
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
<meta name="Generator" content="EditPlus" />
<meta name="Author" content="Jacob Lee" />
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<script src="http://code.jquery.com/jquery-latest.min.js"
type="text/javascript"></script>
<!--<script src="jquery.event.destroyed.js"
type="text/javascript"></script>-->
<script src="http://v3.javascriptmvc.com/jquery/dist/jquery.event.destroyed.js"
type="text/javascript"></script>
</head>
<body>
<!-- Test for jQuery event.destroyed
When a object is destroyed, the event will show -->
<div class="container">
<div class="hello">Hello</div>
<div class="goodbye">Goodbye</div>
</div>
<button onclick="destroy_hello();">Click Me!</button>
<script type="text/javascript">
$(document).ready(function(){
$('.hello').bind('destroyed', function(){alert('goodbye "Hello"!');});
});
function destroy_hello()
{
$('.hello').remove();
}
</script>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> Test for jQuery event.destroyed </title>
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
<meta name="Generator" content="EditPlus" />
<meta name="Author" content="Jacob Lee" />
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<script src="http://code.jquery.com/jquery-latest.min.js"
type="text/javascript"></script>
<!--<script src="jquery.event.destroyed.js"
type="text/javascript"></script>-->
<script src="http://v3.javascriptmvc.com/jquery/dist/jquery.event.destroyed.js"
type="text/javascript"></script>
</head>
<body>
<!-- Test for jQuery event.destroyed
When a object is destroyed, the event will show -->
<div class="container">
<div class="hello">Hello</div>
<div class="goodbye">Goodbye</div>
</div>
<button onclick="destroy_hello();">Click Me!</button>
<script type="text/javascript">
$(document).ready(function(){
$('.hello').bind('destroyed', function(){alert('goodbye "Hello"!');});
});
function destroy_hello()
{
$('.hello').remove();
}
</script>
</body>
</html>
13년 전
정말로 고맙습니다.
SMaker
13년 전
jQuery에 대해서 어느 정도 안다고 생각하고 있었는데 이런 것도 있군요.
좋은 정보 감사합니다.
좋은 정보 감사합니다.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8230 | 9년 전 | 51 | ||
| 8229 | 9년 전 | 52 | ||
| 8228 |
커네드커네드
|
9년 전 | 99 | |
| 8227 | 9년 전 | 108 | ||
| 8226 | 9년 전 | 145 | ||
| 8225 | 9년 전 | 134 | ||
| 8224 | 9년 전 | 132 | ||
| 8223 | 9년 전 | 92 | ||
| 8222 |
|
9년 전 | 162 | |
| 8221 | 9년 전 | 77 | ||
| 8220 | 9년 전 | 75 | ||
| 8219 | 9년 전 | 82 | ||
| 8218 | 9년 전 | 112 | ||
| 8217 |
star3840
|
9년 전 | 98 | |
| 8216 | 9년 전 | 135 | ||
| 8215 | 9년 전 | 89 | ||
| 8214 | 9년 전 | 208 | ||
| 8213 | 9년 전 | 142 | ||
| 8212 | 9년 전 | 57 | ||
| 8211 | 9년 전 | 222 | ||
| 8210 | 9년 전 | 220 | ||
| 8209 | 9년 전 | 319 | ||
| 8208 | 9년 전 | 188 | ||
| 8207 | 9년 전 | 201 | ||
| 8206 |
|
9년 전 | 165 | |
| 8205 | 9년 전 | 147 | ||
| 8204 | 9년 전 | 110 | ||
| 8203 | 9년 전 | 203 | ||
| 8202 | 9년 전 | 127 | ||
| 8201 | 9년 전 | 166 | ||
| 8200 | 9년 전 | 137 | ||
| 8199 | 9년 전 | 187 | ||
| 8198 | 9년 전 | 155 | ||
| 8197 | 9년 전 | 136 | ||
| 8196 | 9년 전 | 520 | ||
| 8195 | 9년 전 | 135 | ||
| 8194 | 9년 전 | 268 | ||
| 8193 | 9년 전 | 136 | ||
| 8192 | 9년 전 | 164 | ||
| 8191 | 9년 전 | 115 | ||
| 8190 | 9년 전 | 112 | ||
| 8189 | 9년 전 | 166 | ||
| 8188 | 9년 전 | 115 | ||
| 8187 | 9년 전 | 121 | ||
| 8186 | 9년 전 | 131 | ||
| 8185 | 9년 전 | 291 | ||
| 8184 | 9년 전 | 87 | ||
| 8183 | 9년 전 | 308 | ||
| 8182 | 9년 전 | 141 | ||
| 8181 | 9년 전 | 114 | ||
| 8180 | 9년 전 | 678 | ||
| 8179 | 9년 전 | 474 | ||
| 8178 | 9년 전 | 278 | ||
| 8177 |
kiplayer
|
9년 전 | 287 | |
| 8176 | 9년 전 | 330 | ||
| 8175 | 9년 전 | 204 | ||
| 8174 | 9년 전 | 211 | ||
| 8173 | 9년 전 | 324 | ||
| 8172 | 9년 전 | 170 | ||
| 8171 | 9년 전 | 161 | ||
| 8170 | 9년 전 | 280 | ||
| 8169 |
커네드커네드
|
9년 전 | 246 | |
| 8168 | 9년 전 | 299 | ||
| 8167 | 9년 전 | 305 | ||
| 8166 | 9년 전 | 218 | ||
| 8165 | 9년 전 | 148 | ||
| 8164 | 9년 전 | 280 | ||
| 8163 | 9년 전 | 266 | ||
| 8162 | 9년 전 | 274 | ||
| 8161 | 9년 전 | 272 | ||
| 8160 |
|
9년 전 | 468 | |
| 8159 | 9년 전 | 388 | ||
| 8158 | 9년 전 | 206 | ||
| 8157 | 9년 전 | 343 | ||
| 8156 | 9년 전 | 257 | ||
| 8155 | 9년 전 | 233 | ||
| 8154 |
00년생용띠
|
9년 전 | 578 | |
| 8153 | 9년 전 | 208 | ||
| 8152 |
|
9년 전 | 386 | |
| 8151 | 9년 전 | 387 | ||
| 8150 | 9년 전 | 479 | ||
| 8149 |
Jangfolk
|
9년 전 | 315 | |
| 8148 | 9년 전 | 149 | ||
| 8147 | 9년 전 | 358 | ||
| 8146 | 9년 전 | 412 | ||
| 8145 | 9년 전 | 344 | ||
| 8144 | 9년 전 | 310 | ||
| 8143 | 9년 전 | 165 | ||
| 8142 | 9년 전 | 411 | ||
| 8141 | 9년 전 | 359 | ||
| 8140 | 9년 전 | 908 | ||
| 8139 | 9년 전 | 233 | ||
| 8138 |
전갈자리남자
|
9년 전 | 376 | |
| 8137 | 9년 전 | 359 | ||
| 8136 | 9년 전 | 717 | ||
| 8135 |
|
9년 전 | 770 | |
| 8134 |
PlayPixel
|
9년 전 | 481 | |
| 8133 |
|
9년 전 | 420 | |
| 8132 | 9년 전 | 431 | ||
| 8131 | 9년 전 | 787 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기