event.stopImmediatePropagation()
event.stopImmediatePropagation()
설명 : 나머지 처리기가 실행되지 않도록 유지하고 이벤트가 DOM 트리 위로 버블 링되는 것을 방지합니다.
요소에 추가 핸들러가 실행되지 않도록하는 것 외에도이 메서드는 암시 적으로 호출하여 버블 링을 중지합니다 event.stopPropagation(). 단순히 이벤트가 조상 요소로 버블 링되는 것을 방지하고 다른 이벤트 처리기를 동일한 요소에서 실행할 수있게하려면 event.stopPropagation()대신 사용할 수 있습니다 .
event.isImmediatePropagationStopped()이 메서드가 (이벤트 객체에서) 호출되었는지 여부를 확인하는 데 사용 합니다.
추가 참고 사항 :
이 .live()메서드는 이벤트가 문서의 맨 위로 전파되면 이벤트를 처리 하므로 라이브 이벤트 전파를 중지 할 수 없습니다. 비슷하게 처리 된 이벤트 .delegate()는 위임 된 요소로 전달됩니다. DOM 트리에서 그 아래에있는 모든 요소에 바인딩 된 이벤트 핸들러는 위임 된 이벤트 핸들러가 호출 될 때까지 이미 실행되었을 것입니다. 따라서 이러한 처리기는 위임 된 처리기가 호출 event.stopPropagation()하거나 반환 하여 트리거하지 못하게 할 수 있습니다 false.
예:
다른 이벤트 처리기가 호출되지 않도록합니다.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>event.stopImmediatePropagation demo</title>
<style>
p {
height: 30px;
width: 150px;
background-color: #ccf;
}
div {
height: 30px;
width: 150px;
background-color: #cfc;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<p>paragraph</p>
<div>division</div>
<script>
$( "p" ).click(function( event ) {
event.stopImmediatePropagation();
});
$( "p" ).click(function( event ) {
// This function won't be executed
$( this ).css( "background-color", "#f00" );
});
$( "div" ).click(function( event ) {
// This function will be executed
$( this ).css( "background-color", "#f00" );
});
</script>
</body>
</html>
게시판 목록
개발자팁
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4796 | jQuery | 8년 전 | 1533 | ||
| 4795 | jQuery | 8년 전 | 1435 | ||
| 4794 | jQuery | 8년 전 | 1562 | ||
| 4793 | jQuery | 8년 전 | 1618 | ||
| 4792 | jQuery | 8년 전 | 1623 | ||
| 4791 | jQuery | 8년 전 | 1794 | ||
| 4790 | jQuery | 8년 전 | 1735 | ||
| 4789 | jQuery | 8년 전 | 1598 | ||
| 4788 | jQuery | 8년 전 | 1660 | ||
| 4787 | jQuery | 8년 전 | 1475 | ||
| 4786 | jQuery | 8년 전 | 1434 | ||
| 4785 | jQuery | 8년 전 | 1644 | ||
| 4784 | jQuery | 8년 전 | 1521 | ||
| 4783 | jQuery | 8년 전 | 1228 | ||
| 4782 | jQuery | 8년 전 | 1598 | ||
| 4781 | jQuery | 8년 전 | 1338 | ||
| 4780 | jQuery | 8년 전 | 1574 | ||
| 4779 | jQuery | 8년 전 | 1983 | ||
| 4778 | jQuery | 8년 전 | 1957 | ||
| 4777 | jQuery | 8년 전 | 1528 | ||
| 4776 | jQuery | 8년 전 | 1582 | ||
| 4775 | jQuery | 8년 전 | 1971 | ||
| 4774 | jQuery | 8년 전 | 1484 | ||
| 4773 | jQuery | 8년 전 | 1410 | ||
| 4772 | jQuery | 8년 전 | 2201 | ||
| 4771 | jQuery | 8년 전 | 3608 | ||
| 4770 | PHP | 8년 전 | 5578 | ||
| 4769 | 기타 | 8년 전 | 1962 | ||
| 4768 | 기타 | 8년 전 | 1781 | ||
| 4767 | 기타 | 8년 전 | 2066 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기