2012-04-24 144 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"]') 
相關問題