I am looking to retrieve the text of the currently selected object.
When I do a $(this).text()
I get all of the available selections
I have tried the following without the desired result:
$(this).text()
$(this).selected()
$(this).selected().text()
$('#simpSR_CodeSet_' + id).off().on('click', function (e) {
app.requireInput('simpSRDet_Units_' + id, false);
app.requireInput('simpSRDet_Visits_' + id, false);
app.requireInput('simpSRDet_Frequency_' + id, false);
let _text = this.selected.text();
alert(_text);
$('#simpSRDet_Units_' + id).val('');
$('#simpSRDet_Visits_' + id).val(1);
$('#simpSRDet_Frequency_' + id).val(1);
$('.srsimplediv_unit_visits_' + id).show();
});
<script id="srsimple_ServiceTemplate" type="text/x-handlebars-template">
<ul class="srsimpledetail">
{{#services}}
<div id="srsimple_service_{{id}}" class="srsimpleService form">
<fieldset>
<dl>
<dt>Service Type:</dt>
<dd>
<select id="simpSR_SvcServiceRequestTypeId_{{id}}"></select></dd>
</dl>
<dl>
<dt>Code Set:</dt>
<dd>
<select id="simpSR_CodeSet_{{id}}" class="InputDD" /></dd>
</dl>
I just want the text of the currently selected item in the list, not all the available items. I need to show/hide fields based on what the text is displaying.
Try this
$("#dropDownId").children("option").filter(":selected").text()