2012-04-24 140 views
-1

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

感谢

+0

你至少应该向我们展示** **渲染HTML。 – gdoron 2012-04-24 06:07:45

+0

是你的工作? – 2012-04-24 06:27:15

回答

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

或jQuery的1.6+:

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

您可以尝试

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

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

注意 RBL是在RadioButtonList的ID

+0

如果它是一个新的jQuery对象,则不应该使用'find'。您使用查找现有的jQuery对象。 – gdoron 2012-04-24 06:06:29

1

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

input[type="radio"][value="2"] 

jQuery中

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