在不使用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>
Run Code Online (Sandbox Code Playgroud)
尝试将该style="visibility:hidden;"属性添加到按钮.另外,考虑使用display:none而display:inline-block不是visibility.
| 归档时间: |
|
| 查看次数: |
13311 次 |
| 最近记录: |