XML
<?xml version="1.0" encoding="utf-8"?>
<Questions>
<Question>
<Id>1</Id>
<Text>aaa</Text>
</Question>
</Questions>
function PopupUserRegist() {
$.ajax({
type: "GET",
url: "Administrator/Questions.xml",
success: parseXml
});
function parseXml(xml)
{
$(xml).find("Question").each(function()
{
var value=$(this).find('Text').text()
$('#<%=sctQuestion.ClientI开发者_运维技巧D %>').
append($("<option></option>").
attr("value",value).
text(value));
});
}
$("#div_userregist").dialog("open");
}
HTML MainMaterPage.aspx
<select runat="server" id="sctQuestion">
<option></option>
This code Automatically Add New Line Content ' ' to option of <select>
select:row 1==' '
select:row 2=='aaaa'
how remove ' '
in first row select
$("#<%=sctQuestion.ClientID %>").removeOption(0);
error say:.removeOption(0); is not a function
You have to clear the list before you start appending:
$('#<%=sctQuestion.ClientID %>').empty()
<select runat="server" id="sctQuestion">
for this
<option></option>
add ' ' to select
精彩评论