在不使用 jQuery 的情况下,当访问者访问页面时,我希望带有文本的按钮"Process"
不可见(在所有浏览器中)。当他们从下拉列表中选择一个值而不是一个值时,first entry (blank)
或者Have a Baby
它使按钮可见。
<html>
<head>
<title>Life Event Picker Calendar</title>
<script>
// Function being used to hide/unhide the button
function changeMessage(oElement) {
if (oElement.value == "100") {
document.getElementById("btn").style.visibility = "hidden";
} else if (oElement.value == "0") {
document.getElementById("btn").style.visibility = "hidden";
} else {
document.getElementById("btn").style.visiblity = "visible";
}
}
</script>
</head>
<body>
...
...
<!-- Based on the selection here - the button below would be made visible -->
<select id="leave" onchange="changeMessage(this);">
<option value="0"></option>
<option value="5">Get Married</option>
<option value="100">Have a Baby</option>
<option value="90">Adopt a Child</option>
<option value="15">Retire</option>
<option value="15">Military Leave</option>
<option value="15">Medical Leave</option>
</select>
<!-- The button in question -->
<button id="btn" onclick="getInfo()"type="button">Process</button>
...
...
</body>
</html>