728x90
반응형
[javascript]
document.querySelector("input[type=radio]:checked").value
-> radio 버튼의 체크된 값의 value 값을 가져온다.
document.getElementsByName("html")
-> radio 버튼의 name이 html인 것들을 모두 가져온다.
인덱스를 통해서 check가 되었는지 확인할 수 있으며, true, false를 반환해준다.
<input type="radio" checked="checked" value="apply" name="html"><label>적용</label>
<input type="radio" value="not apply" name="html"><label>비적용</label>
<script>
var html = document.getElementsByName("html");
alert(html[0].checked); // true
alert(html[1].checked); // false
</script>
[jquery]
$(":radio:checked").val()
-> radio 버튼의 체크된 값의 value 값을 가져온다.
728x90
반응형
'TIL > Web(HTML, CSS, JS, jQuery)' 카테고리의 다른 글
[SIST] Web_javascript_days06_로또 번호 생성 / 테이블에 구구단 출력하기 (0) | 2022.06.08 |
---|---|
[javascript] 이벤트(event) (0) | 2022.06.06 |
[SIST] Web_javascript_days05_달력 만들기 (0) | 2022.06.04 |
[SIST] Web_javascript_days05/days06 (0) | 2022.06.04 |
[SIST] Web_javascript_days05_Date(날짜 객체) (0) | 2022.06.03 |