<select id="Select1">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
alert($("#Select1").val());
이 코드는 올바른지 및 현재 값을 반환합니다.텍스트 가져 오기 해당 Runat 선택 "서버"
BUT
<select runat="server" id="Select1">
<option></option>
</select>
function parseXmlQuestion(xml)
{
$(xml).find("Question").each(function()
{
var value=$(this).find('Text').text()
$('#<%=Select1.ClientID %>').
append($("<option></option>").
attr("value",value).
text(value));
});
}
alert($('#<%=Select1.ClientID %>').val());
alert($('#<%=Select1.ClientID %> option:selected').val());
또는
alert($('#<%=Select1.ClientID %>').text());
alert($('#<%=Select1.ClientID %> option:selected').val());
또는
alert($('#<%=Select1.ClientID %>').html());
alert($('#<%=Select1.ClientID %> option:selected').val());
복귀 뉴 ll 또는 undefined.
실제로'option' 요소를 추가하고 있습니까? 당신이 클라이언트 측 (FireBug와 같은 것)에서 그것을 검사 할 때 실제로 일어나는 것은 무엇입니까? 두 번째 예제는'runat = "server"'보다 많은 변수를 추가합니다. – David
'<% = Select1.ClientID %> '는 무엇을 반환한다고 가정합니까? – Val
왜이 질문을 다시 게시 했습니까 ?? http://stackoverflow.com/questions/5297778/get-current-text-select – Andrew