2

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!

Derek Adair
  • 21,846
  • 31
  • 97
  • 134
user113716
  • 318,772
  • 63
  • 451
  • 440
  • possible duplicate of [How can you programmatically tell an HTML SELECT to drop down (for example, due to mouseover)?](http://stackoverflow.com/questions/249192/how-can-you-programmatically-tell-an-html-select-to-drop-down-for-example-due) – Derek Adair May 06 '15 at 17:52

5 Answers5

2

I don't think this is possible.

You could use a custom drop-down list.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • That's sort of what I was starting to think. Good to know. Won't waste any more time on it. Custom list it is. Thanks much. – user113716 Dec 22 '09 at 01:45
1

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

Derek Adair
  • 21,846
  • 31
  • 97
  • 134
0

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.

Peter Rowell
  • 17,605
  • 2
  • 49
  • 65
0

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

Carlo Pires
  • 4,606
  • 7
  • 32
  • 32
0

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
CAM
  • 185
  • 13
  • Thanks for the effort. Yeah, I had wanted to programmatically display the menu options. FYI, your `blur` solution will cause an infinite loop when the `blur` event is triggered, because it recursively calls itself when you do `$(this).blur()`. But thanks anyway. :) – user113716 Sep 14 '11 at 00:20
  • I was wondering why I kept getting Stackoverflow errors...Thanks – CAM Sep 14 '11 at 17:50