event.preventDefault ()
event.preventDefault ()
설명 : 이 메서드가 호출되면 이벤트의 기본 동작이 트리거되지 않습니다.
예를 들어, 클릭 된 앵커는 브라우저를 새 URL로 가져 가지 않습니다. event.isDefaultPrevented()이 메소드가이 이벤트에 의해 트리거 된 이벤트 핸들러에 의해 호출되었는지 판단 하는 데 사용할 수 있습니다 .
예:
클릭의 기본 동작 (탐색)을 취소합니다.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>event.preventDefault demo</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<a href="http://jquery.com">default click action is prevented</a>
<div id="log"></div>
<script>
$( "a" ).click(function( event ) {
event.preventDefault();
$( "<div>" )
.append( "default " + event.type + " prevented" )
.appendTo( "#log" );
});
</script>
</body>
</html>
게시판 목록
개발자팁
개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4706 | jQuery | 8년 전 | 1517 | ||
| 4705 | jQuery | 8년 전 | 2180 | ||
| 4704 | jQuery | 8년 전 | 1712 | ||
| 4703 | jQuery | 8년 전 | 2048 | ||
| 4702 | jQuery | 8년 전 | 1837 | ||
| 4701 | jQuery | 8년 전 | 2071 | ||
| 4700 | jQuery | 8년 전 | 1750 | ||
| 4699 | jQuery | 8년 전 | 1532 | ||
| 4698 | jQuery | 8년 전 | 1340 | ||
| 4697 | jQuery | 8년 전 | 1755 | ||
| 4696 | jQuery | 8년 전 | 2375 | ||
| 4695 | jQuery | 8년 전 | 1391 | ||
| 4694 | jQuery | 8년 전 | 1804 | ||
| 4693 | jQuery | 8년 전 | 1781 | ||
| 4692 | jQuery | 8년 전 | 2573 | ||
| 4691 | jQuery | 8년 전 | 2080 | ||
| 4690 | jQuery | 8년 전 | 1970 | ||
| 4689 | jQuery | 8년 전 | 1950 | ||
| 4688 | jQuery | 8년 전 | 1708 | ||
| 4687 | jQuery | 8년 전 | 1120 | ||
| 4686 | jQuery | 8년 전 | 1753 | ||
| 4685 | jQuery | 8년 전 | 2497 | ||
| 4684 | jQuery | 8년 전 | 2377 | ||
| 4683 | jQuery | 8년 전 | 1772 | ||
| 4682 | PHP | 8년 전 | 3094 | ||
| 4681 | jQuery | 8년 전 | 1611 | ||
| 4680 | jQuery | 8년 전 | 1800 | ||
| 4679 | PHP | 8년 전 | 2026 | ||
| 4678 | PHP | 8년 전 | 2158 | ||
| 4677 | PHP | 8년 전 | 2260 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기