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에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4766 | jQuery | 8년 전 | 1679 | ||
| 4765 | jQuery | 8년 전 | 1350 | ||
| 4764 | jQuery | 8년 전 | 2168 | ||
| 4763 | jQuery | 8년 전 | 1856 | ||
| 4762 | jQuery | 8년 전 | 1634 | ||
| 4761 | jQuery | 8년 전 | 1936 | ||
| 4760 | jQuery | 8년 전 | 1299 | ||
| 4759 | jQuery | 8년 전 | 1599 | ||
| 4758 | jQuery | 8년 전 | 1314 | ||
| 4757 | jQuery | 8년 전 | 1280 | ||
| 4756 | jQuery | 8년 전 | 1497 | ||
| 4755 | jQuery | 8년 전 | 1651 | ||
| 4754 | jQuery | 8년 전 | 1616 | ||
| 4753 | jQuery | 8년 전 | 1772 | ||
| 4752 | jQuery | 8년 전 | 1522 | ||
| 4751 | jQuery | 8년 전 | 1842 | ||
| 4750 | jQuery | 8년 전 | 1982 | ||
| 4749 | jQuery | 8년 전 | 1442 | ||
| 4748 | PHP | 8년 전 | 2811 | ||
| 4747 | jQuery | 8년 전 | 1393 | ||
| 4746 | jQuery | 8년 전 | 1650 | ||
| 4745 | jQuery | 8년 전 | 1658 | ||
| 4744 | jQuery | 8년 전 | 1537 | ||
| 4743 | jQuery | 8년 전 | 1614 | ||
| 4742 | jQuery | 8년 전 | 1708 | ||
| 4741 | jQuery | 8년 전 | 1600 | ||
| 4740 | jQuery | 8년 전 | 1610 | ||
| 4739 | jQuery | 8년 전 | 1798 | ||
| 4738 | jQuery | 8년 전 | 1315 | ||
| 4737 | jQuery | 8년 전 | 2101 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기