<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에 대해서 어느 정도 안다고 생각하고 있었는데 이런 것도 있군요.
좋은 정보 감사합니다.
좋은 정보 감사합니다.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5730 | 13년 전 | 778 | ||
| 5729 | 13년 전 | 3595 | ||
| 5728 | 13년 전 | 1163 | ||
| 5727 |
freejazzme
|
13년 전 | 1115 | |
| 5726 | 13년 전 | 1457 | ||
| 5725 |
itlang
|
13년 전 | 443 | |
| 5724 | 13년 전 | 522 | ||
| 5723 |
crocojea
|
13년 전 | 1510 | |
| 5722 | 13년 전 | 1995 | ||
| 5721 | 13년 전 | 719 | ||
| 5720 |
쿠우우우우
|
13년 전 | 475 | |
| 5719 | 13년 전 | 621 | ||
| 5718 |
|
13년 전 | 598 | |
| 5717 | 13년 전 | 1454 | ||
| 5716 |
|
13년 전 | 1045 | |
| 5715 | 13년 전 | 475 | ||
| 5714 | 13년 전 | 475 | ||
| 5713 | 13년 전 | 539 | ||
| 5712 |
|
13년 전 | 778 | |
| 5711 | 13년 전 | 704 | ||
| 5710 |
minini
|
13년 전 | 494 | |
| 5709 |
|
13년 전 | 1338 | |
| 5708 | 13년 전 | 694 | ||
| 5707 | 13년 전 | 5867 | ||
| 5706 |
오니기리죠
|
13년 전 | 1030 | |
| 5705 |
HSEngine
|
13년 전 | 661 | |
| 5704 |
Giggle
|
13년 전 | 1703 | |
| 5703 | 13년 전 | 514 | ||
| 5702 |
AMDbest
|
13년 전 | 1428 | |
| 5701 |
|
13년 전 | 2897 | |
| 5700 | 13년 전 | 508 | ||
| 5699 |
미션임파썩을
|
13년 전 | 550 | |
| 5698 | 13년 전 | 635 | ||
| 5697 | 13년 전 | 552 | ||
| 5696 | 13년 전 | 461 | ||
| 5695 |
|
13년 전 | 718 | |
| 5694 | 13년 전 | 456 | ||
| 5693 | 13년 전 | 986 | ||
| 5692 | 13년 전 | 958 | ||
| 5691 |
쉽다zzz
|
13년 전 | 721 | |
| 5690 | 13년 전 | 477 | ||
| 5689 | 13년 전 | 638 | ||
| 5688 | 13년 전 | 1419 | ||
| 5687 | 13년 전 | 470 | ||
| 5686 | 13년 전 | 2457 | ||
| 5685 |
AMDbest
|
13년 전 | 2163 | |
| 5684 | 13년 전 | 2047 | ||
| 5683 | 13년 전 | 1376 | ||
| 5682 |
AMDbest
|
13년 전 | 709 | |
| 5681 | 13년 전 | 3827 | ||
| 5680 |
|
13년 전 | 1691 | |
| 5679 | 13년 전 | 2100 | ||
| 5678 |
|
13년 전 | 537 | |
| 5677 |
mobiler
|
13년 전 | 475 | |
| 5676 | 13년 전 | 1618 | ||
| 5675 | 13년 전 | 596 | ||
| 5674 |
PHPㅡASP프로그래머
|
13년 전 | 1826 | |
| 5673 |
PHPㅡASP프로그래머
|
13년 전 | 1499 | |
| 5672 |
PHPㅡASP프로그래머
|
13년 전 | 1291 | |
| 5671 |
PHPㅡASP프로그래머
|
13년 전 | 1222 | |
| 5670 |
PHPㅡASP프로그래머
|
13년 전 | 4617 | |
| 5669 | 13년 전 | 3053 | ||
| 5668 | 13년 전 | 1424 | ||
| 5667 | 13년 전 | 502 | ||
| 5666 | 13년 전 | 1154 | ||
| 5665 |
Darby
|
13년 전 | 1615 | |
| 5664 | 13년 전 | 1346 | ||
| 5663 | 13년 전 | 1131 | ||
| 5662 | 13년 전 | 796 | ||
| 5661 | 13년 전 | 460 | ||
| 5660 | 13년 전 | 845 | ||
| 5659 | 13년 전 | 712 | ||
| 5658 | 13년 전 | 533 | ||
| 5657 | 13년 전 | 539 | ||
| 5656 | 13년 전 | 992 | ||
| 5655 | 13년 전 | 437 | ||
| 5654 | 13년 전 | 391 | ||
| 5653 |
졸린다젠장
|
13년 전 | 481 | |
| 5652 |
|
13년 전 | 402 | |
| 5651 | 13년 전 | 1033 | ||
| 5650 | 13년 전 | 727 | ||
| 5649 | 13년 전 | 2240 | ||
| 5648 | 13년 전 | 482 | ||
| 5647 | 13년 전 | 757 | ||
| 5646 | 13년 전 | 1495 | ||
| 5645 | 13년 전 | 685 | ||
| 5644 | 13년 전 | 617 | ||
| 5643 |
|
13년 전 | 574 | |
| 5642 |
쿠마하우스
|
13년 전 | 686 | |
| 5641 |
goaway
|
13년 전 | 1084 | |
| 5640 |
쿠마하우스
|
13년 전 | 650 | |
| 5639 | 13년 전 | 677 | ||
| 5638 |
쿠마하우스
|
13년 전 | 1003 | |
| 5637 | 13년 전 | 825 | ||
| 5636 | 13년 전 | 1424 | ||
| 5635 |
goaway
|
13년 전 | 913 | |
| 5634 |
lllolll
|
13년 전 | 423 | |
| 5633 | 13년 전 | 972 | ||
| 5632 | 13년 전 | 4280 | ||
| 5631 | 13년 전 | 583 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기