English 中文(简体)
jquery - how do I make a select menu display itself without clicking it?
原标题:

Using jquery, how would I make a SELECT menu display itself without actually clicking on it?

I tried sending a click() event (in Safari and Firefox) but no luck.

$( #myselectmenu ).click();

Also tried focus() and select() (and various combinations of the three).

Any ideas?

Thanks!

最佳回答

You always have the option of coding your own function to mimic a "select" menu

问题回答

I don t think this is possible.

You could use a custom drop-down list.

Hmmm, onMouseover? But then how do you get it to do the drop down? Feels like there should be some way to invoke that. Never tried it before.

SELECT component is a component to stay away from. Implement you own and, then try mouseenter() and mouseleave() events.

I may be mis understanding but here goes... Your select menu is hidden, and any click you want it to display?

    <!DOCTYPE html>
<html lang="">
<head>
  <meta charset="utf-8">
</head>
 <script type="text/javascript" src="http://www.google.com/jsapi"></script>
        <script type="text/javascript">
            google.load( jquery ,  1 );
        </script>
        <script type="text/javascript">
            $(function(){
                    $( select ).hide();
                    $(document).click(function(){
                        $( select ).show();
                    });
            });//END Doc Ready
        </script>
<body>
    <select>
            <option>blah</option>
    </select>
</body>
</html>

Then I realized you want the DDM to show up so i tried this ... and it did not work. Maybe this gives you an idea?

$(function(){
                    $( select ).bind( blur , function() {
                         $(this).blur();
                         });
                    $(document).click(function(){
                        $( select option ).trigger( blur );
                    });
        });//END Doc Ready




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签