0

在不使用 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>
4

1 回答 1

6

尝试将style="visibility:hidden;"属性添加到按钮。另外,考虑使用display:noneanddisplay:inline-block而不是visibility.

于 2012-08-22T20:42:51.433 回答