string x = "<select><option value='2'>dfgdfh</option><option value='3'>cvncvn</option><option value='4'>cvn</option><option value='5'>dhdfh</option><option value='6'>dfhdfh</option><option selected="selected" value='7'>dfhdfh</option><option value='8'>dfgfdh</option><option value='12'>New type</option></select>"
如何从所选选项中获取文本?
答案 0 :(得分:7)
修复字符串中的语法错误后:...)
$(x).find("option:selected").text()
答案 1 :(得分:3)
$(体).append(X);
$(“select option:selected”)。text();
答案 2 :(得分:0)
<select id ="someid">
<option value='2'>dfgdfh</option>
<option value='3'>cvncvn</option>
<option value='4'>cvn</option>
<option value='5'>dhdfh</option>
<option value='6'>dfhdfh</option>
<option selected="selected" value='7'>dfhdfh</option>
<option value='8'>dfgfdh</option>
<option value='12'>New type</option>
</select>
// string x = $(&#34; #someid option [value =&#39; 2&#39;]&#34;)。text()
string x = $('#someid option:selected').text()
我认为这样的事情可能有所帮助。