隐藏div显示问题

lee3217813 2012-03-26 10:31:05

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function show() {
document.getElementById("div").style.display = "block";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="div" style="display:none">用户名:<asp:TextBox ID="name" runat="server" Width="70px" MaxLength="20"></asp:TextBox></div>
<asp:Button runat="server" Text="显示" ID="btn" OnClientClick="show()" />
</div>
</form>
</body>
</html>

显示 时马上又隐藏了,我只单击了一下,请指教
...全文
102 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
三石-gary 2012-03-26
  • 打赏
  • 举报
回复
http://topic.csdn.net/u/20120319/13/6c1074a6-e77d-4b6e-a750-830617eda782.html
三石-gary 2012-03-26
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 zsx841021 的回复:]

<div id="div" style="display:none">用户名:
[/Quote]
不好意思。。少看见了一个</div>
应该是你做了别的处理吧。。
挨踢直男 2012-03-26
  • 打赏
  • 举报
回复
不会啊? 是不是你asp.net服务器控件上作了另外的处理?
这样试试

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function show() {
document.getElementById("div").style.display = "block";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="div" style="display:none">用户名:<input type='text'/></div>
<input type='button' onclick="show()" />
</div>
</form>
</body>
</html>

三石-gary 2012-03-26
  • 打赏
  • 举报
回复
<div id="div" style="display:none">用户名:
三石-gary 2012-03-26
  • 打赏
  • 举报
回复
style="display:none"
外层是隐藏的

87,990

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧