请教javascript控制Panel的问题
我希望能用javascript控制Panel的隐藏与显示
问题是这样:为什么第一次点击Checkbox1时Panel1就隐藏了,但是不管我再点多少次,Panel都不能在重新现实呢?
代码如下:
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "a.aspx.cs " Inherits= "a " %>
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
<script language= "javascript " type= "text/javascript ">
function Checkbox1_onclick()
{
if (document.all.Checkbox1.Checked)
{document.all.Panel1.style.display= ' ';}
else
{document.all.Panel1.style.display= 'none ';}
}
</script>
</head>
<body>
<input id= "Checkbox1 " type= "checkbox " onclick= "return Checkbox1_onclick() " /> <br />
<asp:Panel ID= "Panel1 " runat= "server " Height= "269px " Width= "553px ">
<asp:Label ID= "Label1 " runat= "server " Text= "Label "> </asp:Label> </asp:Panel>
</body>
</html>
[解决办法]
Checked改成小写就行了:
if (document.all.Checkbox1.Checked)=> > if (document.all.Checkbox1.checked)
[解决办法]
JS对大小敏感;
http://topic.csdn.net/t/20030122/20/1384486.html