JQuery .bind()

Jmnote bot (토론 | 기여)님의 2020년 11월 2일 (월) 02:53 판 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

jQuery bind 함수

2 예시 1[ | ]

<script src="//code.jquery.com/jquery.min.js"></script>
<script>
$(function() {
	$('#button1').bind('click', button_clicked);
	$('#button2').click(button2_clicked);
});

function button_clicked() {
	$('body').append('<br>버튼1 클릭됨');
}



<button id='button1'>버튼1</button>
<button id='button2'>버튼2</button>

3 예시 2: 여러 이벤트 bind[ | ]

<script src="//code.jquery.com/jquery.min.js"></script>
<script>
$(function(){
	$('#textarea1').bind({
		change: textarea1_access,
		click: textarea1_access,
		keydown: textarea1_access,
		blur: textarea1_access,
	});
});
function textarea1_access(event) {
	$('body').append("<br>"+event.type);
}
</script>

<textarea id='textarea1'></textarea>

4 같이 보기[ | ]

5 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}