2011-05-05 53 views

回答

2

我假設你想根據傳遞給它的文本的值來選擇下拉索引?

$("select option[value="+searchText+"]").attr("selected", true); 
1

您的意思是選擇其值在文本框中的選項?

$("#select1").val($("#text1").val()); 

希望這會有所幫助。乾杯

0

選擇由值或文本的下拉列表項,請使用此

//this is to set selected item by value 
$('#dropDownList').val('setToNewValue'); 

//this is to select by text 
var findText = $('#textBoxId').val(); 
$('#dropDownList option'). 
    filter(function() {return ($(this).text() == findText); })). 
    attr('selected', 'selected'); 
相關問題