三个DIV层隐藏显示问题 我有三个DIV层对应三个服务器控件按钮,点击一个按钮弹出对应DIV层进行编辑,其他层除非点击其他按钮否则均不出现,请问这个代码怎么写啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <div id="pdiv" style="display:none"></div><input type="button" onclick="pop();" /><script>function pop(){ document.getElementById("pdiv").style="block"; //其他两个设置为"none";}</script> <script type="text/javascript"> function edit(divid) { var div = document.getElementById(divid); if(div.style.display=="none") { document.getElementById(divid).style.display=""; } else { document.getElementById(divid).style.display="none"; } } </script></head><body> <form id="form1" runat="server"> <div id="div1" style="display:none;">ffffffffff</div> <div id="div2" style="display:none;">ffffffffff</div> <div id="div3" style="display:none;">ffffffffff</div> <input type="button" value="click " onclick="edit('div1')" /> <input type="button" value="click " onclick="edit('div2')" /> <input type="button" value="click " onclick="edit('div3')" /> </form></body></html> div隐藏显示function test() { var div=document.getElementById("div1") div.style.display=div.style.display=="none"?"block":"none"; }Page.RegisterStartUpScript("key",@"getElementById('div').style.display = 'none';") <div id="div1" runat="Server"> </div> div1.Style["Display"] = "Block"; //显示div1.Style["Display"] = "None"; //隐藏 <%@ 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 src="jquery-1.3.2-vsdoc.js" type="text/javascript"></script> <script type="text/javascript"> $(function(){ $("input[name='btnDiv']").click(function(){ var idStr = $(this).attr("id"); var a = idStr.split("_"); $("div[name='divShow']").hide(); $("#div_"+a[1]).show(); }); }); </script></head><body> <form id="form1" runat="server"> <div id="div_1" name="divShow" style="display:none;">1</div> <div id="div_2" name="divShow" style="display:none;">2</div> <div id="div_3" name="divShow" style="display:none;">3</div> <input id="Button_1" name="btnDiv" type="button" value="button" /> <input id="Button_2" name="btnDiv" type="button" value="button" /> <input id="Button_3" name="btnDiv" type="button" value="button" /> </form></body></html> 1F你的意思不符合我的题,我要的是点击了DIV里面的按钮都不会跳到别的页面去 2F3F你们的都只是DIV的显示与隐藏,我要的是能打开一个DIV,然后在里面编辑,编辑完了要转到别的页面的时候才转到别的页面去——————4F你的代码没有反应 <!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>ShowDiv</title><script type="text/javascript"> function showTip(showdiv) { var tipBox = document.getElementById(showdiv); for(var i=1;i<4;i++) { var emp="show"+i; if(showdiv==emp) { tipBox.style.display = "block"; } else { document.getElementById(emp).style.display="none"; } } } </script></head><body><form><div id="show1" name="show1" style="display:none;">show1</div><div id="show2" name="show2" style="display:none;">show2</div><div id="show3" name="show3" style="display:none;">show3</div><input id="Button_1" name="btnDiv1" type="button" value="button1" onclick="showTip('show1')"/><input id="Button_2" name="btnDiv2" type="button" value="button2" onclick="showTip('show2')"/><input id="Button_3" name="btnDiv3" type="button" value="button3" onclick="showTip('show3')"/></form></body></html> 8F你的代码能用,可是还是跟前面的那些朋友一样,在你的DIV层里面放一个按钮点击事件就会发现点一下就跳回默认页面,要想继续在里面编辑就得再次点击才行 终于有高手帮我搞定了,把每个DIV单独放在一个页面内,主页面放一个iframe指向要默认显示的页面,编写点击事件:function sameMethod(i){ if(i==1) { document.getElementById("mainframe").src="Management/UserEdit.aspx"; } if(i==2) { document.getElementById("mainframe").src="Management/NewsEdit.aspx"; } if(i==3) { document.getElementById("mainframe").src="Management/Update.aspx"; } }还是希望有人能帮我写个能把三个DIV放在同一个页面进行编辑的的代码,谢谢大家了哈 17173两台图片分离是怎么做的? datarow数组中的select方法查询求条件 在写程序时出现一个不理解的问题(关于Cookies) 如何去掉select的边框 数据库绑定到树后问题 xslt里面position()函数能用>或者<吗? 动态添加的CheckBox在提交后为什么不见了? 请教各位高手一个关于命名空间的问题. 小鸟初学小作,BBS 一个,请多指教! 网页中多人编辑同一界面的同个人员的信息,怎么防止重复提交啊 询问下ASP.NET模板的一些问题 asp.net怎么通过函数写入Excel文件
<input type="button" onclick="pop();" />
<script>
function pop()
{
document.getElementById("pdiv").style="block";
//其他两个设置为"none";
}
</script>
function edit(divid)
{
var div = document.getElementById(divid);
if(div.style.display=="none")
{
document.getElementById(divid).style.display="";
}
else
{
document.getElementById(divid).style.display="none";
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="div1" style="display:none;">ffffffffff</div>
<div id="div2" style="display:none;">ffffffffff</div>
<div id="div3" style="display:none;">ffffffffff</div>
<input type="button" value="click " onclick="edit('div1')" />
<input type="button" value="click " onclick="edit('div2')" />
<input type="button" value="click " onclick="edit('div3')" />
</form>
</body>
</html>
function test()
{
var div=document.getElementById("div1")
div.style.display=div.style.display=="none"?"block":"none";
}Page.RegisterStartUpScript("key",@"getElementById('div').style.display = 'none';")
<div id="div1" runat="Server">
</div>
div1.Style["Display"] = "Block"; //显示
div1.Style["Display"] = "None"; //隐藏
<%@ 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 src="jquery-1.3.2-vsdoc.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("input[name='btnDiv']").click(function(){
var idStr = $(this).attr("id");
var a = idStr.split("_");
$("div[name='divShow']").hide();
$("#div_"+a[1]).show();
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="div_1" name="divShow" style="display:none;">1</div>
<div id="div_2" name="divShow" style="display:none;">2</div>
<div id="div_3" name="divShow" style="display:none;">3</div>
<input id="Button_1" name="btnDiv" type="button" value="button" />
<input id="Button_2" name="btnDiv" type="button" value="button" />
<input id="Button_3" name="btnDiv" type="button" value="button" />
</form>
</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>ShowDiv</title>
<script type="text/javascript">
function showTip(showdiv) {
var tipBox = document.getElementById(showdiv);
for(var i=1;i<4;i++)
{
var emp="show"+i;
if(showdiv==emp)
{
tipBox.style.display = "block";
}
else
{
document.getElementById(emp).style.display="none";
}
}
}
</script></head><body>
<form>
<div id="show1" name="show1" style="display:none;">show1</div>
<div id="show2" name="show2" style="display:none;">show2</div>
<div id="show3" name="show3" style="display:none;">show3</div>
<input id="Button_1" name="btnDiv1" type="button" value="button1" onclick="showTip('show1')"/>
<input id="Button_2" name="btnDiv2" type="button" value="button2" onclick="showTip('show2')"/>
<input id="Button_3" name="btnDiv3" type="button" value="button3" onclick="showTip('show3')"/>
</form>
</body>
</html>
if(i==1)
{
document.getElementById("mainframe").src="Management/UserEdit.aspx";
}
if(i==2)
{
document.getElementById("mainframe").src="Management/NewsEdit.aspx";
}
if(i==3)
{
document.getElementById("mainframe").src="Management/Update.aspx";
}
}
还是希望有人能帮我写个能把三个DIV放在同一个页面进行编辑的的代码,谢谢大家了哈