获取当前文本
脚本
$(xml).find("FieldMain").each(function() { var value=$(this).find('Title').text() $('#'). append($(""). attr("value",value). text(value)); }); alert($("# option:selected").text());
此retrun
要么
alert($("# option:selected").val());
这个回归未定义
要么
alert($("# option:selected").html());
返回null
我喜欢Cureent Text。 选中的
使用
alert($("#<%=sctFieldMain.ClientID %> option:selected").html());
EDITED
你的问题也重复这个和这个 。
在html()函数之后你不需要半冒号而val不会返回你正在寻找的html。
alert($("#<%=sctFieldMain.ClientID %> option:selected").html());
但是,如果你有以下并想要值“示例”那么你应该使用val()