【发布时间】:2015-02-05 22:03:09
【问题描述】:
我写了这段代码但没有工作,我看不出这个代码有什么问题,谁能帮我解决这个问题。
<html>
<body>
<input type="radio" name="radio" id="radio1">Site 1<br>
<input type="radio" name="radio" id="radio2">Site 2<br>
<input type="submit" onclick="check()" value="Go">
<script>
function check(){
if(document.getElementById('radio1').checked){
window.location="https://www.site1.com";
}
else if(document.getElementById('radio2').checked){
window.location="https://www.site2.com";
}
</script>
</body>
</html>
【问题讨论】:
-
您需要定义“不工作”的含义。
-
你还没有关闭你的函数
-
提示:打开浏览器控制台,这会显示错误。
标签: javascript html radio-button