问题描述:

I'm pretty new to javascript, so please forgive my ignorance. I'm trying to do something that seems like it should be incredibly simple...close a combo box. However, when I use the hide() function, it not only closes the combo box, but it removes it entirely. Is there any way to just close it?

EDIT:

Here's the actual code I'm using

$(window).ready(function ()

{

$('#comboBox .dropdown-menu').mouseleave(function ()

{

$("#comboBox").hide();

});

});

This removes the combo box from the page when the mouse leaves the open combo box. If I replace hide with blur, nothing happens at all.

Edit 2:

Here's the code for my actual list:

<div class="btn-group" id="comboBox">

<button class="btn btn-custom-top dropdown-toggle" data-toggle="dropdown"><span class="caption"></span><span class="caret"></span></button>

<ul class="dropdown-menu">

</ul>

</div>

Edit 3:

Alright, I was obviously confused about what I was doing. No surprise there, as I'm very new to all this. It's not actually a combo box that I'm trying to close. It's a bootstrap dropdown button type, which doesn't really have the same behavior as a combo box. It's looking like there is no function ready-made to do what I want.

网友答案:

If you're talking about a DOM select element, then the best you can do is call blur(), which will close it.

网友答案:

You should call its blur event handler, here is the code using jQuery:

$('#yourSelectId').blur();
相关阅读:
Top