"JavaScript 버튼 비활성화"의 두 판 사이의 차이

잔글 (Jmnote님이 HTML, JavaScript. jQuery 버튼 비활성화 문서를 JavaScript, jQuery 버튼 비활성화 문서로 이동했습니다)
40번째 줄: 40번째 줄:


==같이 보기==
==같이 보기==
*[[버튼]]
* [[버튼]]
*[[getElementById]]
* [[getElementById]]
*[[jQuery .attr()]]
* [[jQuery .attr()]]
* [[jQuery 버튼 수행시간동안 disabled]]


[[분류: HTML]]
[[분류: HTML]]

2016년 12월 1일 (목) 23:04 판

1 개요

HTML button disabled
HTML 버튼 비활성화
  • 버튼이 비활성화되면 onclick도 작동하지 않게 된다.

2 예제 1: HTML

<button onclick="alert('Hello');">Say Hello</button>
<button onclick="alert('World');" disabled='disabled'>Say World</button>

3 예제 2: JavaScript

<button id="btn-hello" onclick="alert('Hello');">Say Hello</button>
<button id="btn-world"  onclick="alert('World');">Say World</button>
<script>
var btn = document.getElementById('btn-world');
btn.disabled = 'disabled';
</script>

4 예제 3: jQuery

<script src="//code.jquery.com/jquery.min.js"></script>
<script>
$(function() {
	$("#btn-hello")
		.click(function() { alert("Hello"); });
	$("#btn-world")
		.attr("disabled","disabled")
		.click(function() { alert("World"); });
});
</script>
<button id="btn-hello">Say Hello</button>
<button id="btn-world">Say World</button>

5 같이 보기

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