1
At the time of click in a <div> the <select> should open.
That way I can open the <select>.
$('.teste').click(function(){
var element = $('#select')[0];
var ev = new MouseEvent('mousedown');
element.dispatchEvent(ev);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="select">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<div class="teste">Aperte-me</div>
The code however does not work in Firefox.
The amazing thing is MDN document MouseEvent.
As I can do mousedown about a <select> in Firefox?
Programmatically open selects is a nightmare, use a custom select, know how to do?
– Sergio
No, I don’t know how to do it.
– DaviAragao
Take a look here: http://answall.com/a/46056/129
– Sergio
Yes, I had seen this question and was using one of the solutions presented to my
<select>, but the text inside it was too big and encavalava in the icon of:before. I used the:beforein a<span>and I was able to format the<select>for Firefox as well.– DaviAragao