I need to access the text of the currently selected object.
When I use $(this).text()
, I end up getting all available selections
I have attempted the following methods without achieving 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 simply want to retrieve the text of the item currently selected in the list, not all available items. This is necessary for displaying or hiding fields based on the displayed text.