In this article, we are going to learn, how we can trigger a click event on the select box or drop-down menu while hovering the mouse using jQuery.
For creating such behavior for a select box, we will use the jQuery attr() method. This method is used to set or return the attributes and values of the selected elements on the webpage. Note that we will not be able to directly trigger the click event on hover, so we are using the attr() method to get the work done.
Approach: We will call the hover() method on the following id or class of the select box. We will use the attr() method to get the size of the select box and in the same method we will change its size to 1, so when we move the cursor out from the select box it gets back to the default size. By using this approach, we will be able to show the whole list on mouse hover and when the user selects any value from the list it goes back to the default view.
Please Login to comment...