如何隐藏下拉菜单标题?我的代码如下:
<select id="menu1" name="Borgerskaber efter erhverv">
<option id="title">Digitale borgerskaber 1679-1910</option>
<option value="https://online.flippingbook.com/view/956512/">Register til borgerskabsprotokol 1679-1887</option>
<option value="https://online.flippingbook.com/view/707957/">Borgerskabsprotokol 1679-1887</option>
<option value="https://online.flippingbook.com/view/208653/">Borgerskabsprotokol 1869-1910</option>
</select>
<script type="text/javascript">
var urlmenu = document.getElementById('menu1'),
title = document.getElementById('title');
urlmenu.onchange = function() {
if (this.options[this.selectedIndex].id != "title") {
window.open(this.options[this.selectedIndex].value );
}
};
</script>
答案 0 :(得分:0)
要使下拉列表中的第一个选项被禁用,请使用“选定的已禁用”
请改用以下内容:
<!doctype html>
<html>
<head>
</head>
<body>
<select id="menu1" name="Borgerskaber_efter_erhverv">
<option id="title" selected disabled>Digitale borgerskaber 1679-1910</option>
<option value="https://online.flippingbook.com/view/956512/">Register til borgerskabsprotokol 1679-1887</option>
<option value="https://online.flippingbook.com/view/707957/">Borgerskabsprotokol 1679-1887</option>
<option value="https://online.flippingbook.com/view/208653/">Borgerskabsprotokol 1869-1910</option>
</select>
<script type="text/javascript">
var urlmenu = document.getElementById('menu1'),
title = document.getElementById('title');
urlmenu.onchange = function() {
if (this.options[this.selectedIndex].id != "title") {
window.open(this.options[this.selectedIndex].value);
}
};
</script>
</body>
</html>