I want to make a searchable input that when it gets focusin shows a dropdown containing list of possible values that fills using server side language. I tried to use focusin on any element that is not one of elements that are involved using code below:
$("body").not($(".dropdownSearch").find("input")).not($(".dropdownSearch").find("a")).on("click focusin", function () {
$(".dropdown-menu").hide();
});
But when I run the code and click on input it actually get focusin on input but after that get focusin on body and focusout occur on input.
And this is html elements:
<div class="dropdownSearch dropdown">
<span><input type="text" id="input1" name="input1" class="dropdown-toggle" /></span>
<span><input type="text" id="input2" name="input2" class="dropdown-toggle" /></span>
<span><input type="text" id="input3" name="input3" class="dropdown-toggle" /></span>
<div class="dropdown-menu">
<a class="dropdown-item">name</a>
<a class="dropdown-item">name</a>
<a class="dropdown-item">name</a>
</div>
</div>
In this code multiple inputs can open same dropdown but change the values using js reads data from JSON files.
Is there any better way? Thanks for any help.