You can put an attribute on li
with the option value and add an event onclick
, when the user clicks on li
you select the option on select
, take the example:
Jsfiddle
HTML
<select name="opcao" id="sel-opcao">
<option>Selecione</option>
<option value="1">Opção 1</option>
<option value="2">Opção 2</option>
<option value="3">Opção 3</option>
</select>
<ul id="lista-opcao">
<li data-value="1">Opção 1</li>
<li data-value="2">Opção 2</li>
<li data-value="3">Opção 3</li>
</ul>
jQuery
$('#lista-opcao li').click(function(){
var id = $(this).attr('data-value');
$('#sel-opcao option').filter('[value="'+id+'"]')
.prop('selected', true);
});
Do not put solved in the title, accept (mark it with a
V
) one of the answers you liked most or the one that solved the problem. If you have any questions you can consult how to accept an answer– rray