I have a drop down list I did not use the HTML select element, I build it with UL. It is working fine now but I have one problem if I click the drop down it will slide down and when I select an element it will slide up. What I want to slide the list up if I click out the div of the list (without choosing any element). I wonder if I can do it using some JQuery but I do not know how to link this situation with JQuery event listener ?? can anybody help me please? This is my js file:
$('.final_dates_list li').live('click',function(){
id = $(this).attr("id");
if(id == 'current')
{
$("#dates_list").find("li").each(function(){
//alert($(this).attr("id"));
$(this).show();
$(this).slideDown('slow');
});
}
else
{
this_id = $(this).attr("id");
$("#dates_list").find("li").each(function(){
//alert($(this).attr("id"));
$(this).hide();
$(this).slideUp('slow');
});
$("#dates_list").find("#current").show();
}
});
css:
div.final_dates_container ul.final_dates_list
{
float:right;
margin:0px;
padding:0px;
width:100px;
line-height: 21px;
overflow: hidden;
border: 1px solid #27292c;
border-radius: 4px;
background: url('bg.png') no-repeat right #494849;
box-shadow:inset 0 0 1px #393939;
-moz-box-shadow:inset 0 0 1px #393939;
-webkit-box-shadow:inset 0 01px #393939;
list-style-type:none;
color:#fff;
font-size:0.8em;
text-align:center;
font-weight:bold;
position:relative;
z-index:9999;
}
div.final_dates_container ul.final_dates_list li:hover
{
text-decoration:underline;
cursor:pointer;
}
div.final_dates_container ul.final_dates_list li
{
border-top:1px solid #eee;
}
HTML:
<div class="final_dates_container">
<table border="1">
<tr>
<td>
<ul id="dates_list" class="final_dates_list">
<li id='current'>0</li>
<li id='-6' style='display:none'>-6</li>
<li id='-5' style='display:none'>-5</li>
<li id='-4' style='display:none'>-4</li>
<li id='-3' style='display:none'>-3</li>
<li id='-2' style='display:none'>-2</li>
<li id='-1' style='display:none'>-1</li>
<li id='0' style='display:none'>0</li>
<li id='1' style='display:none'>1</li>
<li id='2' style='display:none'>2</li>
<li id='3' style='display:none'>3</li>
<li id='4' style='display:none'>4</li>
<li id='5' style='display:none'>5</li>
<li id='6' style='display:none'>6</li>
</ul>
</td>
</tr>
</table>
</div>