Reputation: 2785
How do I make my drop down menu select the value and display it when I select the item let go of my mouse button? BUT NOT when I click the little arrow drop down button.
HTML:
<select name="menu" id="menu"></select>
JS:
$("#menu").click(function () {
var currentSelection = select.options[select.selectedIndex].value;
populate(select.options[select.selectedIndex].value);
});
Problem is is that when I click the down arrow from the selection menu, it thinks I have clicked/selected an item already, and it calls the populate() function right there. How can I change it to only call populate() after I select an item and left click it?
Upvotes: 0
Views: 70
Reputation: 57105
$("#menu").change(function () {
//code here
});
$("#menu").change(function () {
var currentSelection = this.value;
populate(this.value);
});
Upvotes: 2
Reputation: 22711
Try this, You need to use change
handler instead of click
handler
$("#menu").change(function () {
populate($(this).val());
});
Upvotes: 0