我正在尝试向我的网站添加滚动功能。该标签对此很有效,如果选择了一个选项,我想加载一个新网站。继承人我现在有什么。如何使用html选项标签并检查选择了哪个选项?
<body>
<script type="text/javascript">
$('document').ready(function(){
$('#button').click(function(){
var val = document.getElementById("scroll");
if(val.options[val.selectedIndex].value == 1){
window.location.replace("/passbook.html");
}else if(val.options[val.selectedIndex].value == 2){
window.location.replace("/settings.html");
}
});
});
});
</script>
<select id="scroll" style="height:50px; width:150px;" >
<optgroup label="Home">
<option value="0" >Home</option>
</optgroup>
<optgroup label="Page" >
<option value="1" >Page</option>
</optgroup>
<optgroup label="Other" >
<option value="2" >Settings</option>
</optgroup>
</select>
<button type="button">Go</button>
</body>
现在没有什么明显的情况发生,当点击去。我想重定向到这些页面。我知道window.location.replace(你的URL在这里)的作品。有人可以帮助我的JavaScript?