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에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4556 | jQuery |
프로그래머7
|
8년 전 | 1691 | |
| 4555 | jQuery |
프로그래머7
|
8년 전 | 1609 | |
| 4554 | jQuery |
프로그래머7
|
8년 전 | 1662 | |
| 4553 | jQuery |
프로그래머7
|
8년 전 | 2041 | |
| 4552 | PHP | 8년 전 | 1880 | ||
| 4551 | PHP | 8년 전 | 1465 | ||
| 4550 | PHP | 8년 전 | 1708 | ||
| 4549 | jQuery |
프로그래머7
|
8년 전 | 2744 | |
| 4548 | jQuery |
프로그래머7
|
8년 전 | 1441 | |
| 4547 | jQuery |
프로그래머7
|
8년 전 | 1367 | |
| 4546 | jQuery |
프로그래머7
|
8년 전 | 1684 | |
| 4545 | jQuery |
프로그래머7
|
8년 전 | 1710 | |
| 4544 | jQuery |
프로그래머7
|
8년 전 | 1865 | |
| 4543 | jQuery |
프로그래머7
|
8년 전 | 1652 | |
| 4542 | jQuery |
프로그래머7
|
8년 전 | 1584 | |
| 4541 | jQuery |
프로그래머7
|
8년 전 | 1633 | |
| 4540 | jQuery |
프로그래머7
|
8년 전 | 1666 | |
| 4539 | jQuery |
프로그래머7
|
8년 전 | 1863 | |
| 4538 | jQuery |
프로그래머7
|
8년 전 | 1536 | |
| 4537 | jQuery |
프로그래머7
|
8년 전 | 1696 | |
| 4536 | jQuery |
프로그래머7
|
8년 전 | 1934 | |
| 4535 | jQuery |
프로그래머7
|
8년 전 | 1520 | |
| 4534 | jQuery |
프로그래머7
|
8년 전 | 1855 | |
| 4533 | jQuery |
프로그래머7
|
8년 전 | 2344 | |
| 4532 | jQuery |
프로그래머7
|
8년 전 | 1916 | |
| 4531 | PHP |
|
8년 전 | 3710 | |
| 4530 | jQuery |
프로그래머7
|
8년 전 | 1800 | |
| 4529 | jQuery |
프로그래머7
|
8년 전 | 1899 | |
| 4528 | jQuery |
프로그래머7
|
8년 전 | 1697 | |
| 4527 | jQuery |
|
8년 전 | 2697 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기