通常,我使用它$("#id").val()来返回所选选项的值,但这一次它不起作用。所选标签的IDaioConceptName
HTML代码
<label>Name</label>
<input type="text" name="name" />
<select id="aioConceptName">
<option>choose io</option>
<option>roma</option>
<option>totti</option>
</select>
通常,我使用它$("#id").val()来返回所选选项的值,但这一次它不起作用。所选标签的IDaioConceptName
HTML代码
<label>Name</label>
<input type="text" name="name" />
<select id="aioConceptName">
<option>choose io</option>
<option>roma</option>
<option>totti</option>
</select>
You can use $("#drpList").val();
Use the jQuery.val() function for select elements, too:
The .val() method is primarily used to get the values of form elements such as input, select and textarea. In the case of select elements, it returns
nullwhen no option is selected and an array containing the value of each selected option when there is at least one and it is possible to select more because themultipleattribute is present.
$(function() {
$("#aioConceptName").on("change", function() {
$("#debug").text($("#aioConceptName").val());
}).trigger("change");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<select id="aioConceptName">
<option>choose io</option>
<option>roma</option>
<option>totti</option>
</select>
<div id="debug"></div>
尝试此物有所值...
$("select#id_of_select_element option").filter(":selected").val();
或这个文本...
$("select#id_of_select_element option").filter(":selected").text();
You can select using exact selected option : Below will give innerText
While below will give you value.