Context: I'm using jQuery's autocomplete plugin to trigger a show/hide element beneath it. Problem: The event is only triggered when text is typed in the input box, and not when the tag is selected from the autocomplete list.
This is my code:
<input name="Category" id="tags">
<br>
<div id="Sub_Level2">
Sub Category
<select name="SubCategory" required>
<option value="1">Item 1</option>
<option value="2">Item 2</option>
</select>
</div>
The div #Sub_Level2 is shown/hidden according to the text entered inside the input box.
$('input[name=Category]').keyup(function () {
if ($(this).val() == "Green")
$('#Sub_Level2').show();
else
$('#Sub_Level2').hide();
});
This works, however is the tag 'Green' is selected from the autocomplete box, the show/hide does not work. It only works when it is typed in.
How do I adjust this code to trigger the show/hide event of the #Sub_Level2 div when the user clicks a tag on the autocomplete box.
Thanks in advance.