document.getElementById(“remember”).visibility = “hidden”; not working on a checkbox

风格不统一 提交于 2019-12-19 05:17:49

问题


I cannot get the visibility or display properties to work.

Here is the HTML footer:

<div id="footer">
  &copy; 
  <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:

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";

回答1:


There are two problems in your code:

  • The property is called visibility and not visiblity.
  • It is not a property of the element itself but of its .style property.

It's easy to fix. Simple replace this:

document.getElementById("remember").visiblity

with this:

document.getElementById("remember").style.visibility



回答2:


This is the job for style property:

document.getElementById("remember").style.visibility = "visible";



回答3:


you can use

style="display:none"

Ex:

<asp:TextBox ID="txbProv" runat="server" style="display:none"></asp:TextBox>


来源:https://stackoverflow.com/questions/14007629/document-getelementbyidremember-visibility-hidden-not-working-on-a-chec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!