<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에 대해서 어느 정도 안다고 생각하고 있었는데 이런 것도 있군요.
좋은 정보 감사합니다.
좋은 정보 감사합니다.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7730 | 10년 전 | 1314 | ||
| 7729 | 10년 전 | 1171 | ||
| 7728 |
잘살아보자
|
10년 전 | 614 | |
| 7727 |
잘살아보자
|
10년 전 | 510 | |
| 7726 |
잘살아보자
|
10년 전 | 841 | |
| 7725 |
잘살아보자
|
10년 전 | 567 | |
| 7724 |
잘살아보자
|
10년 전 | 484 | |
| 7723 |
잘살아보자
|
10년 전 | 548 | |
| 7722 |
잘살아보자
|
10년 전 | 487 | |
| 7721 |
잘살아보자
|
10년 전 | 518 | |
| 7720 |
잘살아보자
|
10년 전 | 483 | |
| 7719 |
비긴어게인
|
10년 전 | 701 | |
| 7718 |
|
10년 전 | 2548 | |
| 7717 |
잘살아보자
|
10년 전 | 669 | |
| 7716 |
잘살아보자
|
10년 전 | 413 | |
| 7715 |
잘살아보자
|
10년 전 | 445 | |
| 7714 |
잘살아보자
|
10년 전 | 510 | |
| 7713 | 10년 전 | 1791 | ||
| 7712 | 10년 전 | 1730 | ||
| 7711 | 10년 전 | 1115 | ||
| 7710 | 10년 전 | 1408 | ||
| 7709 | 10년 전 | 1528 | ||
| 7708 | 10년 전 | 1468 | ||
| 7707 | 10년 전 | 866 | ||
| 7706 |
별지기천사
|
10년 전 | 580 | |
| 7705 | 10년 전 | 1085 | ||
| 7704 |
ICONdesignstudio
|
10년 전 | 637 | |
| 7703 | 10년 전 | 604 | ||
| 7702 |
|
10년 전 | 742 | |
| 7701 | 10년 전 | 1430 | ||
| 7700 | 10년 전 | 1116 | ||
| 7699 | 10년 전 | 586 | ||
| 7698 | 10년 전 | 1157 | ||
| 7697 | 10년 전 | 5180 | ||
| 7696 | 10년 전 | 672 | ||
| 7695 | 10년 전 | 1697 | ||
| 7694 | 10년 전 | 1080 | ||
| 7693 | 10년 전 | 1568 | ||
| 7692 | 10년 전 | 1311 | ||
| 7691 | 10년 전 | 836 | ||
| 7690 | 10년 전 | 1398 | ||
| 7689 | 10년 전 | 1028 | ||
| 7688 | 10년 전 | 633 | ||
| 7687 |
파랑새1597
|
10년 전 | 611 | |
| 7686 | 10년 전 | 864 | ||
| 7685 | 10년 전 | 1351 | ||
| 7684 | 10년 전 | 811 | ||
| 7683 | 10년 전 | 1118 | ||
| 7682 | 10년 전 | 1038 | ||
| 7681 | 10년 전 | 681 | ||
| 7680 | 10년 전 | 998 | ||
| 7679 | 10년 전 | 521 | ||
| 7678 | 10년 전 | 750 | ||
| 7677 | 10년 전 | 650 | ||
| 7676 |
|
10년 전 | 958 | |
| 7675 |
|
10년 전 | 1190 | |
| 7674 | 10년 전 | 1057 | ||
| 7673 | 10년 전 | 764 | ||
| 7672 | 10년 전 | 1104 | ||
| 7671 | 10년 전 | 915 | ||
| 7670 | 10년 전 | 681 | ||
| 7669 |
mashmellow
|
10년 전 | 1240 | |
| 7668 | 10년 전 | 729 | ||
| 7667 | 10년 전 | 1024 | ||
| 7666 |
senseme
|
10년 전 | 668 | |
| 7665 | 10년 전 | 523 | ||
| 7664 | 10년 전 | 1907 | ||
| 7663 |
mixx애교
|
10년 전 | 988 | |
| 7662 | 10년 전 | 1056 | ||
| 7661 |
hkhkah
|
10년 전 | 801 | |
| 7660 | 10년 전 | 1076 | ||
| 7659 |
커네드커네드
|
10년 전 | 945 | |
| 7658 |
바람돌이팡
|
10년 전 | 686 | |
| 7657 | 10년 전 | 1175 | ||
| 7656 | 10년 전 | 1587 | ||
| 7655 | 10년 전 | 1005 | ||
| 7654 |
개발짜증나
|
10년 전 | 867 | |
| 7653 |
네이비칼라
|
10년 전 | 889 | |
| 7652 |
밥먹고합시다
|
10년 전 | 819 | |
| 7651 |
플라이SINJI
|
10년 전 | 1521 | |
| 7650 |
개발짜증나
|
10년 전 | 1430 | |
| 7649 | 10년 전 | 460 | ||
| 7648 |
이미영ㅇㅇ
|
10년 전 | 881 | |
| 7647 | 10년 전 | 452 | ||
| 7646 | 10년 전 | 822 | ||
| 7645 | 10년 전 | 2333 | ||
| 7644 | 10년 전 | 829 | ||
| 7643 |
|
10년 전 | 2882 | |
| 7642 | 10년 전 | 1527 | ||
| 7641 | 10년 전 | 1150 | ||
| 7640 |
개발짜증나
|
10년 전 | 479 | |
| 7639 |
|
10년 전 | 823 | |
| 7638 |
개발짜증나
|
10년 전 | 1144 | |
| 7637 | 10년 전 | 1564 | ||
| 7636 | 10년 전 | 2921 | ||
| 7635 | 10년 전 | 1711 | ||
| 7634 | 10년 전 | 1899 | ||
| 7633 | 10년 전 | 2358 | ||
| 7632 | 10년 전 | 3965 | ||
| 7631 |
|
10년 전 | 1554 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기