Jquery-ajax解析xml并设置radiobutton
我有一个带有一些单选按钮的表单,如下所示:
<input type="radio" name="leva" value="a"><input type="radio" name="leva" value="b">
使用ajax post方法我收到单选按钮的值。 问题是如何设置正确的单选值来检查?
提前致谢 再见 h.
I've a form with some radio button like this:
<input type="radio" name="leva" value="a"><input type="radio" name="leva" value="b">
with ajax post method I receive value of the radio.
The question is how can I set correct radio value to checked?
thanks in advance
ciao
h.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需要使用 属性等于选择器 作为值找到正确的按钮,然后使用
.attr()
checked 属性a>,像这样:浏览器将处理取消选择其他选项的情况,因为它是一个单选按钮,如果没有找到带有
value
的按钮...好吧,就像所有 jQuery 选择器一样,它只是不会有任何效果,这通常是我们想要的。You just need to find the right button using an attribute equals selector for the value, then set
checked
attribute using.attr()
, like this:The browser will handle un-selecting the other options since it's a radio button, and if no button is found with the
value
...well, like all jQuery selectors, it just won't have any effect, which is usually what's desired.