내 기본을 올바르게 얻으려는 DOM/javascript 초보자. 난 그냥 그것을 클릭하면 라디오 버튼의 동작을 관찰하려고 해요. 내 코드를 heres. 나를 혼란 무엇라디오 버튼의 동작
HTML
<script src="tmp.js"></script>
<input type="radio" id="inp1" name="same" onclick="show();"/>
<input type="radio" id="inp2" name="same" onclick="show();"/>
JS (tmp.js)
function show() {
alert(document.getElementById("inp1").value + " " + document.getElementById("inp2").value);
}
는 경고 상자를 실행에있는 버튼 중 하나를 클릭에 "에서의"말한다는 것이다. "on off"또는 "off on"하지 않아야합니까?
function show() {
alert(document.getElementById("inp1").checked + " " +
document.getElementById("inp2").checked);
}
근무 예 : 당신이 얻고 싶은 것은 checked
재산처럼
없다 – Esailija