event.data
event.data
설명 : 현재 실행 핸들러가 바인드 될 때 이벤트 메소드에 전달되는 데이터의 선택적 객체입니다.
예:
for루프 내 i에서 .on()메서드 의 값을 전달 하여 현재 반복 값이 보존되도록합니다.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>event.data demo</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<button> 0 </button>
<button> 1 </button>
<button> 2 </button>
<button> 3 </button>
<button> 4 </button>
<div id="log"></div>
<script>
var logDiv = $( "#log" );
for ( var i = 0; i < 5; i++ ) {
$( "button" ).eq( i ).on( "click", { value: i }, function( event ) {
var msgs = [
"button = " + $( this ).index(),
"event.data.value = " + event.data.value,
"i = " + i
];
logDiv.append( msgs.join( ", " ) + "<br>" );
});
}
</script>
</body>
</html>
게시판 목록
개발자팁
개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4796 | jQuery | 8년 전 | 1535 | ||
| 4795 | jQuery | 8년 전 | 1439 | ||
| 4794 | jQuery | 8년 전 | 1564 | ||
| 4793 | jQuery | 8년 전 | 1620 | ||
| 4792 | jQuery | 8년 전 | 1633 | ||
| 4791 | jQuery | 8년 전 | 1794 | ||
| 4790 | jQuery | 8년 전 | 1735 | ||
| 4789 | jQuery | 8년 전 | 1599 | ||
| 4788 | jQuery | 8년 전 | 1660 | ||
| 4787 | jQuery | 8년 전 | 1475 | ||
| 4786 | jQuery | 8년 전 | 1434 | ||
| 4785 | jQuery | 8년 전 | 1645 | ||
| 4784 | jQuery | 8년 전 | 1528 | ||
| 4783 | jQuery | 8년 전 | 1233 | ||
| 4782 | jQuery | 8년 전 | 1601 | ||
| 4781 | jQuery | 8년 전 | 1340 | ||
| 4780 | jQuery | 8년 전 | 1576 | ||
| 4779 | jQuery | 8년 전 | 1985 | ||
| 4778 | jQuery | 8년 전 | 1959 | ||
| 4777 | jQuery | 8년 전 | 1529 | ||
| 4776 | jQuery | 8년 전 | 1583 | ||
| 4775 | jQuery | 8년 전 | 1971 | ||
| 4774 | jQuery | 8년 전 | 1488 | ||
| 4773 | jQuery | 8년 전 | 1412 | ||
| 4772 | jQuery | 8년 전 | 2203 | ||
| 4771 | jQuery | 8년 전 | 3614 | ||
| 4770 | PHP | 8년 전 | 5579 | ||
| 4769 | 기타 | 8년 전 | 1965 | ||
| 4768 | 기타 | 8년 전 | 1781 | ||
| 4767 | 기타 | 8년 전 | 2068 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기