开发者

get current text <select>

                 <select runat="server" id="sctFieldMain">
                 <option></option>
                   </select>

Script

   $(xml).find("FieldMain").each(function()
 { 
    var value=$(this).find('Title').text()
     $('#<%=sctFieldMain.ClientID %>').
      append($("<option></option>").
      attr("value",value).
      text(value)); 
  });

 alert($("#<%=sctFieldMain.ClientID %> option:selected").text());

this r开发者_如何学JAVAetrun <%=sctFieldMain.ClientID %>

or

alert($("#<%=sctFieldMain.ClientID %> option:selected").val());

this retrun undefined

or

alert($("#<%=sctFieldMain.ClientID %> option:selected").html());

return null

i like get Cureent Text. that selected


Use

alert($("#<%=sctFieldMain.ClientID %> option:selected").html());

EDITED

Also your question duplicates this one and this.


You don't need the semi colon after the html() function and val does not return the html which is what your looking for.

alert($("#<%=sctFieldMain.ClientID %> option:selected").html());

However if you had the following and wanted the value "Example" then you should use val()

<option value="example">some test</option>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜