Skip to content Skip to sidebar Skip to footer

How Open/close Options Of 'select' When You Click On Anyone 'div'

I have open/close 'options' of 'select' on click anyone 'div' or 'button'. How this done by javaScript or JQuery. Thanks.

Solution 1:

If what you're asking is how to cause a drop-down select to drop down programmatically (e.g., in response to a click somewhere else that triggers your code), you can't do that.


Solution 2:

You can easily simulate a click on an element, but a click on a <select> won’t open up the dropdown.

$('div').bind('click', function() {
     // code for open and close your select
});

Here the reference Can I open a dropdownlist using jQuery


Solution 3:

If you want to manipulate a <select> control, you can try using its size property. If its size is > 1, it will display options. Something along the lines of:

[somediv].onclick = function(){
  [someselect].size = 10;
}

Like T.J. Crowder rightfully remarked, this doesn't 'open' a dropdown, but it offers the possibility (using styling etc.) to simulate it.


Post a Comment for "How Open/close Options Of 'select' When You Click On Anyone 'div'"