我写了这段代码但没有工作,我在这个coad上看不出任何错误,任何人都可以帮我解决这个问题.
<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>
Run Code Online (Sandbox Code Playgroud)