1 개요[ | ]
- jQuery bind 함수
- jQuery 이벤트를 다른 함수로 연결(bind)해주는 함수
2 예시 1[ | ]
html
Copy
<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[ | ]
html
Copy
<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 참고[ | ]
편집자 Jmnote bot Jmnote 61.34.132.202 61.254.192.62
로그인하시면 댓글을 쓸 수 있습니다.