js问题 <asp:RadioButton ID="rdoYes" runat="server" GroupName="Sj" Text="是"/>现在有个单选按钮 要控制一个层的显示和隐藏 JS代码怎么写 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 OnSelectedIndexChanged 在服务端事件中处理,向客户端注册脚本或者运行后,用JQuery给rdoYes的子项绑定$("<%=rdoYes.ClientID%> > input").click( function(){$('#myDiv').toggle();}); 搞成RadioButtonList去了一个的话,直接写客户端事件 block 和null 就可以直接设置啊 block none 我不知道怎么写了 现在是服务器控件 <asp:RadioButton ID="rdoYes" runat="server" GroupName="Sj" Text="是"/> <asp:RadioButton ID="rdoNo" runat="server" Checked="true" GroupName="Sj" Text="否" />2个按钮 我不懂Jquery 能给我代码吗 急啊 <div id="层隐藏" runat="server" style="display: none"> <div id="层显示" runat="server" style="display: block"> 后台:层隐藏.Style.Add("display", "block"); --显示.层显示.Style.Add("display", "none"); --隐藏. 可以,$("id").slideToggle('slow'); Jquery这样写.你要用JS就是:function checkJiaoyu() { 判断按钮 获取ID:rdoYes和rdoNo是否为null, rdoYes为null:document.getElementById("层id").style.display="none" --隐藏 rdoNo为null:document.getElementById("层id").style.display="block" --显示 } 不能判断为null。判断为:.checked属性,还以为这段代码是判断生成的,只有一个有,另一个为空... 用html的标签,别加runat="server"响应客户端事件执行js 是的,给你的两个单选按钮都加上一个客户端事件<asp:RadioButton ID="rdoYes" runat="server" GroupName="Sj" Text="是" onclick="toggleDiv(true)" /><asp:RadioButton ID="rdoNo" runat="server" Checked="true" GroupName="Sj" Text="否" onclick="toggleDiv(false)" />function toggleDiv(isShow){ document.getElementById("Div的ID").style.display = isShow ? "block" : "none";} 把你写的代码贴出来别告诉我你直接用的getElementById("Div的ID") 应该是文档DOM还未加载完就点了按钮,呵呵把那个function移到</form>后面去或者用JQuery $(document).ready(),不过那也不用写那么麻烦了 加个容错判断好了function toggleDiv(isShow){ if(document.getElementById("Div的ID") == null) return; document.getElementById("Div的ID").style.display = isShow ? "block" : "none";} 、不报错了 但是不显示层 <asp:RadioButton ID="rdoYes" runat="server" GroupName="Sj" Text="是" onclick="toggleDiv(true)" /> <asp:RadioButton ID="rdoNo" runat="server" Checked="true" GroupName="Sj" Text="否" onclick="toggleDiv(false)" /> <div style="display: none;" id="divSJ" runat="server"> <table id="Table2"> <tr> <td align="left">结束时间:</td> <td colspan="3"> <SharePoint:DateTimeControl ID="dtTime" runat="server"> </SharePoint:DateTimeControl> </td> </tr> </table> </div>function toggleDiv(isShow){ if(document.getElementById("Div的ID") == null) return; document.getElementById("divSJ").style.display = (isShow) ? "block" : "none";} documnet。getelementById(“”)里面的id用生成页面之后查看源文件里的那个id 可以,$("id").slideToggle('slow'); Jquery这样写.你要用JS就是:function checkJiaoyu() { 判断按钮 获取ID:rdoYes和rdoNo是否为null, rdoYes为null:document.getElementById("层id").style.display="none" --隐藏 rdoNo为null:document.getElementById("层id").style.display="block" --显示 }用radiobuttonlist <!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 id="Head1" runat="server"><title>系统登录</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script> var test = function(temp){ document.getElementById("div").style.display=temp; } </script></head><body><form id="login_form" runat="server" method="post"><asp:RadioButton ID="rdoYes" runat="server" GroupName="Sj" Text="是" onclick="test('block')"/> <asp:RadioButton ID="rdoNo" runat="server" Checked="true" GroupName="Sj" Text="否" onclick="test('none')" /> <div id="div">div</div></form></body></html> <div style="display: none;" id="divSJ" runat="server">这里你必须得使用服务端的div吗?下面那个改了,上面那个怎么不改掉<script type="text/javascript">function toggleDiv(isShow){ var myDiv = document.getElementById("<%=divSJ.ClientID%>"); if(myDiv == null) return; myDiv.style.display = (isShow) ? "block" : "none";}</script> listbox单击事件的问题 hubble demo gridview TextBox值读不出来??? 急救小弟? 购物车 TextBox 还是没有修改???? 在web端怎么动态的添加控件 asp.net配置文件的问题 制作虚拟"网络堵塞现象" 请教两个.net显示数据问题 怎样制造个简单的ASP登陆页面 如何升级到Windows XP Professional安装IIS 紧急求救,谢谢大侠版主帮忙,提示一下。 请问有用win7做开发的吗? 正则表达式含义
或者运行后,用JQuery给rdoYes的子项绑定
$("<%=rdoYes.ClientID%> > input").click(
function(){$('#myDiv').toggle();}
);
一个的话,直接写客户端事件
<asp:RadioButton ID="rdoNo" runat="server" Checked="true" GroupName="Sj" Text="否" />
2个按钮 我不懂Jquery 能给我代码吗 急啊
<div id="层显示" runat="server" style="display: block">
层隐藏.Style.Add("display", "block"); --显示.
层显示.Style.Add("display", "none"); --隐藏.
function checkJiaoyu() {
判断按钮 获取ID:rdoYes和rdoNo是否为null,
rdoYes为null:document.getElementById("层id").style.display="none" --隐藏
rdoNo为null:document.getElementById("层id").style.display="block" --显示
}
判断为:.checked属性,
还以为这段代码是判断生成的,只有一个有,另一个为空...
是的,给你的两个单选按钮都加上一个客户端事件
<asp:RadioButton ID="rdoYes" runat="server" GroupName="Sj" Text="是" onclick="toggleDiv(true)" />
<asp:RadioButton ID="rdoNo" runat="server" Checked="true" GroupName="Sj" Text="否" onclick="toggleDiv(false)" />function toggleDiv(isShow){
document.getElementById("Div的ID").style.display = isShow ? "block" : "none";
}
应该是文档DOM还未加载完就点了按钮,呵呵
把那个function移到</form>后面去
或者用JQuery $(document).ready(),不过那也不用写那么麻烦了
if(document.getElementById("Div的ID") == null) return;
document.getElementById("Div的ID").style.display = isShow ? "block" : "none";
}
不报错了 但是不显示层 <asp:RadioButton ID="rdoYes" runat="server" GroupName="Sj" Text="是" onclick="toggleDiv(true)" />
<asp:RadioButton ID="rdoNo" runat="server" Checked="true" GroupName="Sj" Text="否" onclick="toggleDiv(false)" /> <div style="display: none;" id="divSJ" runat="server">
<table id="Table2">
<tr>
<td align="left">结束时间:</td>
<td colspan="3">
<SharePoint:DateTimeControl ID="dtTime" runat="server">
</SharePoint:DateTimeControl>
</td>
</tr>
</table>
</div>function toggleDiv(isShow){
if(document.getElementById("Div的ID") == null) return; document.getElementById("divSJ").style.display = (isShow) ? "block" : "none";
}
function checkJiaoyu() {
判断按钮 获取ID:rdoYes和rdoNo是否为null,
rdoYes为null:document.getElementById("层id").style.display="none" --隐藏
rdoNo为null:document.getElementById("层id").style.display="block" --显示
}用radiobuttonlist
<!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 id="Head1" runat="server">
<title>系统登录</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script>
var test = function(temp){
document.getElementById("div").style.display=temp;
}
</script>
</head>
<body>
<form id="login_form" runat="server" method="post">
<asp:RadioButton ID="rdoYes" runat="server" GroupName="Sj" Text="是" onclick="test('block')"/>
<asp:RadioButton ID="rdoNo" runat="server" Checked="true" GroupName="Sj" Text="否" onclick="test('none')" />
<div id="div">div</div>
</form>
</body>
</html>
<div style="display: none;" id="divSJ" runat="server">这里你必须得使用服务端的div吗?
下面那个改了,上面那个怎么不改掉
<script type="text/javascript">
function toggleDiv(isShow){
var myDiv = document.getElementById("<%=divSJ.ClientID%>");
if(myDiv == null) return;
myDiv.style.display = (isShow) ? "block" : "none";
}
</script>