<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에 대해서 어느 정도 안다고 생각하고 있었는데 이런 것도 있군요.
좋은 정보 감사합니다.
좋은 정보 감사합니다.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5830 | 13년 전 | 1185 | ||
| 5829 | 13년 전 | 5049 | ||
| 5828 | 13년 전 | 6430 | ||
| 5827 | 13년 전 | 1202 | ||
| 5826 |
|
13년 전 | 529 | |
| 5825 | 13년 전 | 895 | ||
| 5824 |
|
13년 전 | 1880 | |
| 5823 | 13년 전 | 5615 | ||
| 5822 |
jfascas
|
13년 전 | 1038 | |
| 5821 | 13년 전 | 1696 | ||
| 5820 | 13년 전 | 1311 | ||
| 5819 |
itlang
|
13년 전 | 506 | |
| 5818 | 13년 전 | 1305 | ||
| 5817 | 13년 전 | 780 | ||
| 5816 | 13년 전 | 624 | ||
| 5815 | 13년 전 | 6132 | ||
| 5814 | 13년 전 | 860 | ||
| 5813 |
악마의유혹
|
13년 전 | 461 | |
| 5812 | 13년 전 | 2801 | ||
| 5811 | 13년 전 | 1172 | ||
| 5810 | 13년 전 | 3532 | ||
| 5809 | 13년 전 | 1354 | ||
| 5808 | 13년 전 | 1061 | ||
| 5807 | 13년 전 | 571 | ||
| 5806 | 13년 전 | 559 | ||
| 5805 |
angrysol
|
13년 전 | 816 | |
| 5804 | 13년 전 | 1005 | ||
| 5803 | 13년 전 | 1730 | ||
| 5802 |
angrysol
|
13년 전 | 1049 | |
| 5801 |
후라보노보노
|
13년 전 | 2136 | |
| 5800 | 13년 전 | 1100 | ||
| 5799 |
|
13년 전 | 4189 | |
| 5798 |
|
13년 전 | 3359 | |
| 5797 |
|
13년 전 | 4932 | |
| 5796 | 13년 전 | 7536 | ||
| 5795 | 13년 전 | 2776 | ||
| 5794 | 13년 전 | 2228 | ||
| 5793 |
|
13년 전 | 656 | |
| 5792 | 13년 전 | 2969 | ||
| 5791 | 13년 전 | 842 | ||
| 5790 | 13년 전 | 4328 | ||
| 5789 |
|
13년 전 | 2474 | |
| 5788 |
|
13년 전 | 1849 | |
| 5787 |
오지랖선생
|
13년 전 | 1617 | |
| 5786 | 13년 전 | 5923 | ||
| 5785 | 13년 전 | 1743 | ||
| 5784 |
|
13년 전 | 1449 | |
| 5783 | 13년 전 | 1304 | ||
| 5782 |
|
13년 전 | 2818 | |
| 5781 | 13년 전 | 2852 | ||
| 5780 | 13년 전 | 1155 | ||
| 5779 |
|
13년 전 | 1358 | |
| 5778 |
오리진소프트
|
13년 전 | 4608 | |
| 5777 | 13년 전 | 676 | ||
| 5776 | 13년 전 | 1139 | ||
| 5775 | 13년 전 | 1452 | ||
| 5774 | 13년 전 | 1873 | ||
| 5773 |
|
13년 전 | 1910 | |
| 5772 | 13년 전 | 1674 | ||
| 5771 | 13년 전 | 4782 | ||
| 5770 | 13년 전 | 1126 | ||
| 5769 | 13년 전 | 6106 | ||
| 5768 |
|
13년 전 | 1576 | |
| 5767 | 13년 전 | 1684 | ||
| 5766 |
프로프리랜서
|
13년 전 | 1380 | |
| 5765 |
|
13년 전 | 1035 | |
| 5764 | 13년 전 | 1760 | ||
| 5763 |
|
13년 전 | 779 | |
| 5762 |
|
13년 전 | 2283 | |
| 5761 | 13년 전 | 615 | ||
| 5760 | 13년 전 | 621 | ||
| 5759 | 13년 전 | 3269 | ||
| 5758 | 13년 전 | 1075 | ||
| 5757 |
|
13년 전 | 737 | |
| 5756 | 13년 전 | 562 | ||
| 5755 | 13년 전 | 1057 | ||
| 5754 |
|
13년 전 | 2223 | |
| 5753 | 13년 전 | 671 | ||
| 5752 | 13년 전 | 1542 | ||
| 5751 | 13년 전 | 762 | ||
| 5750 | 13년 전 | 746 | ||
| 5749 | 13년 전 | 2564 | ||
| 5748 | 13년 전 | 998 | ||
| 5747 | 13년 전 | 1213 | ||
| 5746 |
|
13년 전 | 643 | |
| 5745 | 13년 전 | 1656 | ||
| 5744 | 13년 전 | 665 | ||
| 5743 | 13년 전 | 826 | ||
| 5742 |
프로프리랜서
|
13년 전 | 575 | |
| 5741 | 13년 전 | 636 | ||
| 5740 | 13년 전 | 614 | ||
| 5739 | 13년 전 | 721 | ||
| 5738 | 13년 전 | 1920 | ||
| 5737 | 13년 전 | 977 | ||
| 5736 | 13년 전 | 1085 | ||
| 5735 | 13년 전 | 1988 | ||
| 5734 | 13년 전 | 1135 | ||
| 5733 | 13년 전 | 2775 | ||
| 5732 |
JOYCOM
|
13년 전 | 631 | |
| 5731 | 13년 전 | 3298 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기