OPEN SELECT when "Hover" or "Focus"

Asked

Viewed 183 times

2

I’ve searched several sites, but I did not find one that was what I wanted, the ones I saw expand the select using the size and that’s not what I want, I want as if it was a user click on the select, it does not push anything down, or take up more space, just appears on the other options, overriding what is underneath.

Here, one of my tests, but this is not how I want.

$("#contPrazo").hover(function(){
  $("#contPrazo").attr("size","4");
});
$("#contPrazo").focus(function(){
  $("#contPrazo").attr("size","4");
});

$("#contPrazo").mouseleave(function(){
  $("#contPrazo").attr("size","1");
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select id="contPrazo" name="contPrazo">
	<option value="30">30 MESES</option>
	<option value="12">12 MESES</option>
	<option value="24">24 MESES</option>
	<option value="36">36 MESES</option>
	<option value="48">48 MESES</option>
</select>

  • 1

    From what I researched here, it is not possible to open it no. Maybe you can create a dropdown to do this, rather than a select.

  • 1

    You can create a component, using UL/LI but with the appearance of a Select, ai yes with CSS or JS is easier to manipulate. If this can be an option for you... Bootstrap itself does not have a select, its select is built with other HTML elements

  • use bootstrap, but I don’t know this "select" of them, in my Forms always use <select class="form-control" id="" name="">

1 answer

-1

According to this link of the SO and this another link, and in addition to others I have consulted to answer your question, after I myself have tried, options of a SELECT, with the mouse pass.

On the other hand, I believe the supposed SELECT that you mentioned in your question correlate to a dropbox, which probably associated with some JS function fills some input:hidden with the value corresponding to li clicked.

  • yes would be a dropdown, I want to do this for a form, then a dropdown that just sends to another page, or something like that does not suit me, would be a select even, I select and that when sending the form comes in GET/POST

  • 1

    You can add an event in the dropdown that fills in some hidden form field, causing your data to be sent.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.