开发者

jQuery: Get value of selected radio group when name is an array?

I have a group of radio group like below and I am having problems getting the selected/checked value. I think is it because the name is an array. I renamed my id's to the same to see if I could do it that way but no luck.

<input type="radio" name="accounts[1][details][status]" value=开发者_如何学编程"1" id="status_1" />
<input type="radio" name="accounts[1][details][status]" value="2" id="status_1" />

Thanks


This should do it. See jQuery docs on escaping special characters.

$('input[name="accounts\\[1\\]\\[details\\]\\[status\\]"]:checked').val();


You're looking for :checked to get the one that is selected

<input type="radio" name="accounts[1][details][status]" value="1" class="status" />
<input type="radio" name="accounts[1][details][status]" value="2" class="status" />

jQuery: 

$(".status").change(function ()
{
    var checked_value = $(".status:checked").val();
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜