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에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4826 | jQuery | 8년 전 | 1668 | ||
| 4825 | JavaScript | 8년 전 | 2733 | ||
| 4824 | jQuery | 8년 전 | 1460 | ||
| 4823 | jQuery | 8년 전 | 1721 | ||
| 4822 | jQuery | 8년 전 | 1805 | ||
| 4821 | jQuery | 8년 전 | 1632 | ||
| 4820 | jQuery | 8년 전 | 1646 | ||
| 4819 | jQuery | 8년 전 | 1324 | ||
| 4818 | jQuery | 8년 전 | 1963 | ||
| 4817 | jQuery | 8년 전 | 2404 | ||
| 4816 | jQuery | 8년 전 | 1697 | ||
| 4815 | jQuery | 8년 전 | 1414 | ||
| 4814 | jQuery | 8년 전 | 1834 | ||
| 4813 | jQuery | 8년 전 | 5408 | ||
| 4812 | 기타 | 8년 전 | 3158 | ||
| 4811 | jQuery | 8년 전 | 1540 | ||
| 4810 | jQuery | 8년 전 | 1707 | ||
| 4809 | jQuery | 8년 전 | 1794 | ||
| 4808 | PHP |
|
8년 전 | 5080 | |
| 4807 | node.js |
|
8년 전 | 4108 | |
| 4806 | jQuery | 8년 전 | 2208 | ||
| 4805 | jQuery | 8년 전 | 1642 | ||
| 4804 | jQuery | 8년 전 | 1191 | ||
| 4803 | jQuery | 8년 전 | 1905 | ||
| 4802 | jQuery | 8년 전 | 1409 | ||
| 4801 | jQuery | 8년 전 | 1519 | ||
| 4800 | jQuery | 8년 전 | 1739 | ||
| 4799 | jQuery | 8년 전 | 1980 | ||
| 4798 | jQuery | 8년 전 | 1519 | ||
| 4797 | jQuery | 8년 전 | 1449 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기