我有如下类似的代码...

<p><label>Do you have buffet facilities?</label>
  <asp:RadioButtonList ID="blnBuffetMealFacilities:chk" runat="server">
    <asp:ListItem Text="Yes" Value="1"></asp:ListItem>
    <asp:ListItem Text="No" Value="0"></asp:ListItem>
  </asp:RadioButtonList></p>
<div id="HasBuffet">
  <p><label>What is the capacity for the buffet?</label>
  <asp:RadioButtonList ID="radBuffetCapacity" runat="server">
    <asp:ListItem Text="Suitable for upto 30 guests" value="0 to 30"></asp:ListItem>
    <asp:ListItem Text="Suitable for upto 50 guests" value="30 to 50"></asp:ListItem>
    <asp:ListItem Text="Suitable for upto 75 guests" value="50 to 75"></asp:ListItem>
    <asp:ListItem Text="Suitable for upto 100 guests" value="75 to 100"></asp:ListItem>
    <asp:ListItem Text="Suitable for upto 150 guests" value="100 to 150"></asp:ListItem>
    <asp:ListItem Text="Suitable for upto 250 guests" value="150 to 250"></asp:ListItem>
    <asp:ListItem Text="Suitable for upto 400 guests" value="250 to 400"></asp:ListItem>
  </asp:RadioButtonList></p>
</div>

我想捕捉一个事件,当广播列表BLBuffettMealFacilities:chk更改客户端并在jQuery的HasBuffet div上执行向下滑动功能时.要做到这一点,最好的方法是什么?请记住,页面上有几个类似的部分,我希望根据广播列表中的是非答案来显示问题.

推荐答案

这是:

$('#rblDiv input').click(function(){
    alert($('#rblDiv input').index(this));
});

将为您获取单击的单选按钮的索引(我认为,未经测试)(请注意,您必须将RBL包装在#rblDiv中)

you could then use that to display the corresponding div like 这是:

$('.divCollection div:eq(' + $('#rblDiv input').index(this) +')').show();

这就是你的意思吗?

编辑:另一种方法是为RBL指定一个类名,然后执行:

$('.rblClass').val();

Asp.net相关问答推荐

无法翻译 LINQ

我可以将图像添加到 ASP.NET 按钮吗?

从数据库中检索数据的最快方法

VS2012 中无法识别的标签前缀或设备过滤器asp

IIS Request.UserHostAddress 返回 IPV6 (::1),即使禁用了 IPV6

IIS 将旧用户名返回到我的应用程序

ASP.NET MVC4 jquery/javascript 包的使用

将 null 转换为字符串的函数

使用 JavaScript 禁用 ASP.NET 验证器

如何在 ASP.NET 中仅在调试模式下执行代码

如何设置 CSS 切换器

IIS Express - 增加内存限制

HttpResponse.End 或 HttpResponse.Close 与 HttpResponse.SuppressContent

模型是否包含字段而不将其添加到数据库中?

IIS 8.0 ASP.NET 和错误 500.19

将Bundle 包添加到现有的 ASP.NET Webforms 解决方案

LinkBut​​ton 向 OnClick 后面的代码发送值

IIS 是否执行非法字符替换?如果是这样,如何阻止它?

可以在不 destruct 站点的情况下将 MIME 类型添加到 web.config 吗?

RegisterStartupScript 不适用于 ScriptManager、Updatepanel.这是为什么?