<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에 대해서 어느 정도 안다고 생각하고 있었는데 이런 것도 있군요.
좋은 정보 감사합니다.
좋은 정보 감사합니다.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8130 | 9년 전 | 587 | ||
| 8129 |
|
9년 전 | 706 | |
| 8128 | 9년 전 | 556 | ||
| 8127 |
|
9년 전 | 601 | |
| 8126 | 9년 전 | 536 | ||
| 8125 | 9년 전 | 786 | ||
| 8124 |
|
9년 전 | 547 | |
| 8123 | 9년 전 | 535 | ||
| 8122 | 9년 전 | 462 | ||
| 8121 | 9년 전 | 575 | ||
| 8120 | 9년 전 | 487 | ||
| 8119 | 9년 전 | 577 | ||
| 8118 |
|
9년 전 | 655 | |
| 8117 |
|
9년 전 | 421 | |
| 8116 |
PASKRAN
|
9년 전 | 482 | |
| 8115 | 9년 전 | 481 | ||
| 8114 |
kiplayer
|
9년 전 | 621 | |
| 8113 | 9년 전 | 476 | ||
| 8112 |
|
9년 전 | 586 | |
| 8111 | 9년 전 | 420 | ||
| 8110 | 9년 전 | 465 | ||
| 8109 | 9년 전 | 392 | ||
| 8108 |
|
9년 전 | 570 | |
| 8107 |
|
9년 전 | 458 | |
| 8106 |
|
9년 전 | 460 | |
| 8105 | 9년 전 | 493 | ||
| 8104 |
|
9년 전 | 455 | |
| 8103 |
|
9년 전 | 458 | |
| 8102 |
|
9년 전 | 429 | |
| 8101 |
snshero
|
9년 전 | 819 | |
| 8100 | 9년 전 | 860 | ||
| 8099 | 9년 전 | 839 | ||
| 8098 | 9년 전 | 743 | ||
| 8097 | 9년 전 | 548 | ||
| 8096 | 9년 전 | 751 | ||
| 8095 | 9년 전 | 889 | ||
| 8094 | 9년 전 | 562 | ||
| 8093 | 9년 전 | 841 | ||
| 8092 | 9년 전 | 782 | ||
| 8091 | 9년 전 | 1168 | ||
| 8090 | 9년 전 | 795 | ||
| 8089 | 9년 전 | 1005 | ||
| 8088 | 9년 전 | 668 | ||
| 8087 | 9년 전 | 792 | ||
| 8086 | 9년 전 | 543 | ||
| 8085 | 9년 전 | 508 | ||
| 8084 | 9년 전 | 631 | ||
| 8083 | 9년 전 | 600 | ||
| 8082 | 9년 전 | 791 | ||
| 8081 | 9년 전 | 500 | ||
| 8080 | 9년 전 | 599 | ||
| 8079 | 9년 전 | 557 | ||
| 8078 | 9년 전 | 474 | ||
| 8077 | 9년 전 | 561 | ||
| 8076 | 9년 전 | 432 | ||
| 8075 | 9년 전 | 464 | ||
| 8074 | 9년 전 | 435 | ||
| 8073 | 9년 전 | 488 | ||
| 8072 | 9년 전 | 478 | ||
| 8071 |
o1o111
|
9년 전 | 929 | |
| 8070 | 9년 전 | 435 | ||
| 8069 | 9년 전 | 375 | ||
| 8068 | 9년 전 | 625 | ||
| 8067 | 9년 전 | 421 | ||
| 8066 | 9년 전 | 448 | ||
| 8065 | 9년 전 | 409 | ||
| 8064 | 9년 전 | 403 | ||
| 8063 | 9년 전 | 372 | ||
| 8062 | 9년 전 | 340 | ||
| 8061 | 9년 전 | 378 | ||
| 8060 | 9년 전 | 419 | ||
| 8059 | 9년 전 | 357 | ||
| 8058 | 9년 전 | 294 | ||
| 8057 | 9년 전 | 420 | ||
| 8056 | 9년 전 | 340 | ||
| 8055 | 9년 전 | 391 | ||
| 8054 | 9년 전 | 395 | ||
| 8053 | 9년 전 | 446 | ||
| 8052 | 9년 전 | 315 | ||
| 8051 | 9년 전 | 362 | ||
| 8050 | 9년 전 | 420 | ||
| 8049 | 9년 전 | 352 | ||
| 8048 | 9년 전 | 455 | ||
| 8047 | 9년 전 | 395 | ||
| 8046 | 9년 전 | 340 | ||
| 8045 | 9년 전 | 288 | ||
| 8044 | 9년 전 | 381 | ||
| 8043 | 9년 전 | 335 | ||
| 8042 | 9년 전 | 326 | ||
| 8041 | 9년 전 | 386 | ||
| 8040 | 9년 전 | 303 | ||
| 8039 | 9년 전 | 349 | ||
| 8038 | 9년 전 | 287 | ||
| 8037 | 9년 전 | 431 | ||
| 8036 | 9년 전 | 521 | ||
| 8035 | 9년 전 | 456 | ||
| 8034 | 9년 전 | 413 | ||
| 8033 | 9년 전 | 377 | ||
| 8032 | 9년 전 | 484 | ||
| 8031 | 9년 전 | 375 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기