Reputation: 724
I have dynamically created option where all values in option are coming from share point list . Now I want to get the text of selected option . I tried few ways but I was not able to get
$("#ddlIncrementType").append(
$("<option></option>")
.data("incrementLevel", results[increment].IncrementLevel)
.val(results[increment].Title)
.html(results[increment].Title)
);
<div class="Increment">
<label for="sel1">Increment Type:</label>
<select disabled class="form-control" id="ddlIncrementType">
<option></option>
</select>
</div>
I want to get the text of Selected Option Suppose in list there are three options
I want exactly text Anyone who can help ?
I tried it but does't not worked !
var value = $("#ddlIncrementType").find(":selected").val();
var selectedText = $("#mySelect option:selected").html();
var value = $("#ddlIncrementType").find(":selected").text();
Upvotes: 2
Views: 2314
Reputation: 170
You could use-
$(document).on('change', "#ddlIncrementType", function(){
var value = $(this).text();
alert(value);
});
Also you should not be using disabled
for your <select>
Upvotes: 1