Why is the ul
disappearing with display: none
when the input element is clicked?
Here is the HTML code snippet:
When this input is clicked:
<input class="input country" type="text"/>
This unordered list should be displayed (but it's not):
<ul id='country-list'>
<li id="US">United States</li>
</ul>
Check out the jQuery code below:
function handleCountries() {
$('#country-list').hide();
$('#country').click(function () {
$("#country-list").show();
});
};
function handleTestOut() {
handleCountries()
};
$(handleTestOut)
HTML structure to showcase the issue:
<div class="container">
<input class="input country" type="text"/>
<ul id='country-list'>
<li id="US">United States</li>
</ul>
<button>explore</button>
</div>
Here are some CSS styles being applied:
.container {
position: relative;
display: flex;
flex-direction: column;
height: 200px;
}
.input {
height: 30px;
margin-bottom: 50px;
}
ul {
height: 200px;
width: 18%;
overflow: hidden;
overflow-y: scroll;
position: absolute;
background-color: blue;
top: 20px
}
Note: Invalid HTML has been removed, but the issue persists