"JQuery 클릭 이벤트"의 두 판 사이의 차이

1번째 줄: 1번째 줄:
{{소문자}}
{{소문자}}
==개요==
;jQuery 클릭 이벤트
;jQuery 클릭 이벤트
;jQuery .click()


==예시==
==예시1: input button==
*브라우저에서 문서를 모두 읽어들인 후에(ready), 모든 p 태그의 클릭 이벤트(click)에 숨김기능(hide)을 넣었다.
<source lang='html5'>
<source lang='html5'>
<!DOCTYPE html>
<script src="//code.jquery.com/jquery.min.js"></script>
<html lang="ko">
 
<head>
<input type='button' id="button1" value='버튼1'/>
<meta charset="utf-8" />
 
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script>
<script type="text/javascript">
$("#button1").click(function() {
$(document).ready(function(){
alert("버튼1을 누르셨습니다.");
  $("p").click(function(){
});
    $(this).hide();
</script>
  });
</source>
<jsfiddle>y779gh34</jsfiddle>
 
==예시2: button==
<source lang='html5'>
<script src="//code.jquery.com/jquery.min.js"></script>
 
<button id="button1">버튼1</button>
 
<script>
$("#button1").click(function() {
alert("버튼1을 누르셨습니다.");
});
});
</script>
</script>
</head>
<body>
<p>클릭하면 사라집니다 1</p>
<p>클릭하면 사라집니다 2</p>
</body>
</html>
</source>
</source>
<jsfiddle>900hzc02</jsfiddle>


==같이 보기==
==같이 보기==

2016년 2월 3일 (수) 21:38 판

1 개요

jQuery 클릭 이벤트
jQuery .click()

2 예시1: input button

<script src="//code.jquery.com/jquery.min.js"></script>

<input type='button' id="button1" value='버튼1'/>

<script>
$("#button1").click(function() {
	alert("버튼1을 누르셨습니다.");
});
</script>

3 예시2: button

<script src="//code.jquery.com/jquery.min.js"></script>

<button id="button1">버튼1</button>

<script>
$("#button1").click(function() {
	alert("버튼1을 누르셨습니다.");
});
</script>

4 같이 보기

5 참고 자료

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