hey guys, I'm trying to build a simple custom select box with jquery.
html:
<div class="select">
<ul>
<li class="option darr">Dropdown one</li>
<li class="option">Dropdown two</li>
<li class="option">Dropdown three</li>
<ul>
</div>
jquery:
$('.select ul li.option').click(function() {
$(this).siblings().toggle().removeClass('darr');
$(this).addClass('darr');
})
You can check out the working example right here: http://jsfiddle.net/WFTvq/2/
This works fine actually, however there is one little thing that bugs me. When I click on the custom select field all options are shown. If I do not choose one of the options and click anywhere else on the window the dropdown does not collapse autamatically.
A normal select box would collapse if I click anywhere else on the screen, how could I implement that behaviour in my example?
Thank you
h