jQuery open select by button

前端 未结 7 1112
小蘑菇
小蘑菇 2021-01-11 15:33

How to open select dropdown by button?

$(\'button\').on(\'click\', function() {
   $(\'select\').trigger(\'click\');
});

My code: http://js

7条回答
  •  情话喂你
    2021-01-11 15:48

    I think this will help you..

    Trigger documentation

    $('button').on('click', function() {
        $('select').trigger('click');
    });
    
    $('select').click(function(){
    alert($(this).val());
    });
    

    Fiddle Here

提交回复
热议问题