jquery 检查 onload 选中了哪个单选按钮
给定以下 html
<input id="IBE1_IBE_NurFlug1_RadioButtonList1_0"
name="IBE1$IBE_NurFlug1$RadioButtonList1" value="Blue" type="radio">
<label for="IBE1_IBE_NurFlug1_RadioButtonList1_0">Blue</label>
<input id="IBE1_IBE_NurFlug1_RadioButtonList1_1"
name="IBE1$IBE_NurFlug1$RadioButtonList1" value="Green" checked="checked"
type="radio">
<label for="IBE1_IBE_NurFlug1_RadioButtonList1_1">Green</label>
我如何执行类似的操作
如果选中蓝色单选按钮,则... 如果选中绿色单选按钮,请执行...
提前致谢...
given following html
<input id="IBE1_IBE_NurFlug1_RadioButtonList1_0"
name="IBE1$IBE_NurFlug1$RadioButtonList1" value="Blue" type="radio">
<label for="IBE1_IBE_NurFlug1_RadioButtonList1_0">Blue</label>
<input id="IBE1_IBE_NurFlug1_RadioButtonList1_1"
name="IBE1$IBE_NurFlug1$RadioButtonList1" value="Green" checked="checked"
type="radio">
<label for="IBE1_IBE_NurFlug1_RadioButtonList1_1">Green</label>
how can I perform actions like
If radiobutton blue is checked do ...
If radiobutton green is checked do...
thanks in advance...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 attribute-equals (用于名称匹配)和
:checked
选择器,如下所示:您可以在这里测试。
由于您似乎在 ASP.Net 中,因此您的页面中需要一个像这样的选择器:
这是 attribute-ends-with 选择器,用于处理 ASP.Net 附加的命名容器前缀。
Use the attribute-equals (for the name match) and
:checked
selectors, like this:You can test it here.
Since you seem to be in ASP.Net though, you'll need a selector like this in your page:
This is the attribute-ends-with selector, to handle the naming container prefixes that ASP.Net appends.
抓住选中的项目并测试其值。
});
grab the checked item and test against its value.
});