Javascript document.getElementById("记住").visibility = "隐藏"; 不处理复选框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14007629/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
document.getElementById("remember").visibility = "hidden"; not working on a checkbox
提问by Ben
I cannot get the visibilityor displayproperties to work.
我无法使visibility或display属性工作。
Here is the HTML footer:
这是 HTML 页脚:
<div id="footer">
©
<strong id="foot" onmouseover="showData();" onmouseout = "hideData()">
Exquisite Taste 2012
</strong>
<input type='checkbox' id="remember" onclick='editCookie()' style="visibility:hidden;" />
</div>
Here is the .js function with the visibility part not working:
这是可见性部分不起作用的 .js 函数:
function showData()
{
document.getElementById("remember").visiblity="visible";
document.getElementById("foot").innerHTML = getDate() + " " + getTime();
if(cookieValue())
{
document.getElementById("remember").checked = true;
}
}
That one line doesn't seem to do anything:
那一行似乎没有做任何事情:
document.getElementById("remember").visiblity="visible";
回答by ThiefMaster
There are two problems in your code:
您的代码中有两个问题:
- The property is called
visibilityand notvisiblity. - It is not a property of the element itself but of its
.styleproperty.
- 该属性被称为
visibility而不是visiblity。 - 它不是元素本身的属性,而是它的
.style属性。
It's easy to fix. Simple replace this:
很容易修复。简单替换这个:
document.getElementById("remember").visiblity
with this:
有了这个:
document.getElementById("remember").style.visibility
回答by VisioN
This is the job for styleproperty:
这是style财产的工作:
document.getElementById("remember").style.visibility = "visible";
回答by DrWeather
you can use
您可以使用
style="display:none"
Ex:
前任:
<asp:TextBox ID="txbProv" runat="server" style="display:none"></asp:TextBox>

