aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/api/globaleventhandlers/onclick
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:17 -0500
commitda78a9e329e272dedb2400b79a3bdeebff387d47 (patch)
treee6ef8aa7c43556f55ddfe031a01cf0a8fa271bfe /files/ko/web/api/globaleventhandlers/onclick
parent1109132f09d75da9a28b649c7677bb6ce07c40c0 (diff)
downloadtranslated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.gz
translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.bz2
translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.zip
initial commit
Diffstat (limited to 'files/ko/web/api/globaleventhandlers/onclick')
-rw-r--r--files/ko/web/api/globaleventhandlers/onclick/index.html89
1 files changed, 89 insertions, 0 deletions
diff --git a/files/ko/web/api/globaleventhandlers/onclick/index.html b/files/ko/web/api/globaleventhandlers/onclick/index.html
new file mode 100644
index 0000000000..9b655c0421
--- /dev/null
+++ b/files/ko/web/api/globaleventhandlers/onclick/index.html
@@ -0,0 +1,89 @@
+---
+title: GlobalEventHandlers.onclick
+slug: Web/API/GlobalEventHandlers/onclick
+tags:
+ - API
+ - Event Handler
+ - HTML DOM
+ - Property
+ - Reference
+translation_of: Web/API/GlobalEventHandlers/onclick
+---
+<div>{{apiref("HTML DOM")}}</div>
+
+<p>{{domxref("GlobalEventHandlers")}} 믹스인<sup>mixin</sup>의 <code><strong>onclick</strong></code> 속성은 주어진 요소의 {{event("click")}} 이벤트를 처리하기 위한 {{domxref("EventHandler")}}입니다.</p>
+
+<p><code>click</code> 이벤트는 사용자가 요소를 클릭할 때 {{event("mousedown")}}과 {{event("mouseup")}} 다음으로 발동합니다.</p>
+
+<div class="note"><strong>참고:</strong> <code>click</code> 이벤트에 행동을 붙일 땐, 마우스나 터치 스크린을 사용하지 않는 사용자도 그 행동을 할 수 있도록 {{event("keydown")}}이벤트에도 똑같이 적용하는걸 고려해보세요.</div>
+
+<h2 id="Syntax" name="Syntax">구문</h2>
+
+<pre class="syntaxbox">target.onclick = <var>functionRef</var>;
+</pre>
+
+<h3 id="값">값</h3>
+
+<p><code>functionRef</code>는 함수 이름이거나 <a href="/ko/docs/Web/JavaScript/Reference/Operators/function">함수 표현식</a>으로, 유일한 매개변수로 {{domxref("MouseEvent")}} 객체를 받습니다. 함수 내에서 {{jsxref("Operators/this", "this")}}는 이벤트가 발동한 요소를 가리킵니다.</p>
+
+<p>하나의 객체에는 하나의 <code>onclick</code> 처리기만 할당할 수 있습니다. 더 유연한{{domxref("EventTarget.addEventListener()")}} 메서드를 선호하는 편이 좋을 수도 있습니다.</p>
+
+<h2 id="예제">예제</h2>
+
+<p>다음 예제는 클릭 위치를 기록합니다.</p>
+
+<h3 id="HTML">HTML</h3>
+
+<pre class="brush: html">&lt;p&gt;Click anywhere in this example.&lt;/p&gt;
+&lt;p id="log"&gt;&lt;/p&gt;</pre>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<pre class="brush: js">let log = document.getElementById('log');
+
+document.onclick = inputChange;
+
+function inputChange(e) {
+ log.textContent = `Position: (${e.clientX}, ${e.clientY})`;
+}</pre>
+
+<h3 id="결과">결과</h3>
+
+<p>{{EmbedLiveSample("예제")}}</p>
+
+<h2 id="Specification" name="Specification">명세</h2>
+
+<table class="spectable standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML WHATWG','webappapis.html#handler-onclick','onclick')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="브라우저_호환성">브라우저 호환성</h2>
+
+<div>
+
+
+<p>{{Compat("api.GlobalEventHandlers.onclick")}}</p>
+</div>
+
+<h2 id="같이_보기">같이 보기</h2>
+
+<ul>
+ <li>{{event("click")}} 이벤트</li>
+ <li>관련 이벤트 처리기
+ <ul>
+ <li>{{domxref("GlobalEventHandlers.onauxclick")}}</li>
+ <li>{{domxref("GlobalEventHandlers.ondblclick")}}</li>
+ </ul>
+ </li>
+</ul>