如何根据值选择元素

时间:2012-04-24 05:59:59

标签: javascript jquery asp.net radiobuttonlist

HowI可以根据值选择元素吗?例如,我想在RadiobuttonList控件中选择具有value=2的输入。

感谢

3 个答案:

答案 0 :(得分:1)

你可以尝试

$("#<%=rbl.ClientID%> input[value=2]").attr('checked', true);  

$('#<%=rbl.ClientID %>').find("input[value=2]").attr("checked", "checked");

注意 rbl是radiobuttonlist的ID

答案 1 :(得分:1)

$('#{id of RadiobuttonList} input[value="2"]').attr('checked', 'checked')

或jQuery 1.6 +:

$('#{id of RadiobuttonList} input[value="2"]').prop('checked', true)

答案 2 :(得分:1)

你可以使用这个css选择器:

input[type="radio"][value="2"]
在jquery中

$('input[type="radio"][value="2"]')
相关问题