When I press the enter key in an input field, I want to be able to select options from a searchable dropdown menu. However, this functionality is not working and the alert message I set up is also not functioning as expected.
<div class="form-group m-form__group row">
<label class="col-form-label col-lg-2">Tags</label>
<div class="col-8">
<select class="form-control m-bootstrap-select" id="add_tag" data-live-search="true" name="tags">
<option value="1">tag</option>
</select>
</div>
</div>
How can I achieve this functionality? The code snippet I am using is not producing the desired results.
$(document).ready(function () {
$('#add_tag').keypress(function (e) {
var key = e.which;
if(key == 13)
{
alert(123);
}
});
});