我有类似下面的代码…
<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>
我想捕获一个事件,当radio list blBuffetMealFacilities:chk更改客户端和执行一个向下滑动功能的HasBuffet div从jQuery。创建这个的最好方法是什么,请记住,在页面上有几个类似的部分,我想要问的问题显示,取决于在电台列表中的是否答案。
解决方法
这个:
$('#rblDiv input').click(function(){
alert($('#rblDiv input').index(this));
});
会得到你点击的单选按钮的索引(我认为,未测试)(注意,你不得不包装你的RBL在#rblDiv
你可以使用它来显示相应的div像这样:
$('.divCollection div:eq(' + $('#rblDiv input').index(this) +')').show();
这是你的意思吗?
编辑:另一种方法是给rbl一个类名,然后去:
$('.rblClass').val();