JS控制DIV显示与隐藏问题 在同一个asp.net 页面上有一个查询列表和查询选项,查询选项放在一个DIV里边,默认其display为none,通过一个“显示查询选项”按钮执行js来让此DIV显示。 输入查询条件后,点击查询按钮,此时页面会重新加载,这样DIV又被隐藏了…… 我想实现的是,当用户查询后,被显示的DIV仍然保持显示状态,高手帮忙! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <div id="DIV1" runat=server>在点击事件里,写DIV1.Attributes.Add("style","display:block");在Page_Load事件里写if(!Page.IsPostBack){ DIV1.Attributes.Add("style","display:none");} <!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><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title><script src="http://code.jquery.com/jquery-latest.js"></script><script>$(document).ready(function(){ $("#btn").click(function(){ $("#chaxun").fadeIn(1000); });});</script></head><body><div id="chaxun" style="display:none">查询显示</div><input type="button" value="查询" id="btn" /></body></html>其他的效果楼主自己加上就可以了 楼主 通过 asp.net 来控制当 “查询按钮” 被点击 后 控制 div 的style的属性为 block因为页面重新载入;但用 JS还是控制不了的 <!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><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title><script src="http://code.jquery.com/jquery-latest.js"></script><script language="javascript">function displaydiv(){ document.getElementById('query').style.display='block';}</script></head><body><div id="query" style="display:none">查询显示</div><input type="button" value="显示查询选项" id="btn" onclick="displaydiv()"/></body></html> 你问题解决了吗、我也遇到过类似的问题我是在窗体加载的时候做了个判断,在地址栏多加了一个参数、窗体加载的时候判断参数的值,从而让div显示或不显示 不要用JS了直接用Panel控件 然后显示按钮返回后台设置 Panel的显示,隐藏 JQuery一个特效代码页面N处用,效果会一起动… ext3.2 tabPanel单击事件 利用ASP或JS求出输入的字符串的正则表达式,谁会逆向? 请问jquery中如何在全局变量中定义jquery对象? 根据状态显示不同的页面内容。 高分求解!大家帮忙看下这段代码有什么问题!为什么总报这个错误!急,在线! 如何做一个计时器,实现hh:mm:ss效果 获取当天时间 jq widgets pie 显示颜色问题 利用层模拟windows窗口,可以托动!高手进!稻草人...阿信...100分! js外部链接问题 请教拖拽图片的实现思路
在Page_Load事件里写
if(!Page.IsPostBack)
{
DIV1.Attributes.Add("style","display:none");
}
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("#btn").click(function(){
$("#chaxun").fadeIn(1000);
});
});</script>
</head>
<body>
<div id="chaxun" style="display:none">查询显示</div>
<input type="button" value="查询" id="btn" />
</body>
</html>其他的效果楼主自己加上就可以了
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script language="javascript">
function displaydiv()
{
document.getElementById('query').style.display='block';
}</script>
</head>
<body>
<div id="query" style="display:none">查询显示</div>
<input type="button" value="显示查询选项" id="btn" onclick="displaydiv()"/>
</body>
</html>
我是在窗体加载的时候做了个判断,在地址栏多加了一个参数、窗体加载的时候判断参数的值,从而让div显示或不显示
直接用Panel控件
然后显示按钮返回后台设置 Panel的显示,隐藏