Trigger click on select box on hover

后端 未结 6 1372
孤独总比滥情好
孤独总比滥情好 2020-11-30 13:10

I\'m trying to have a select box automatically pop open when the use hovers over it, as if they had clicked it. Is this possible?

I would think I could

6条回答
  •  -上瘾入骨i
    2020-11-30 13:42

    It's been a while but there is a solution I don't see here, using hover to change the length of select :

    $('select').hover(function() {
    
      $(this).attr('size', $('option').length);
    }, function() {
    
      $(this).attr('size', 1);
    });
    

    http://codepen.io/anon/pen/avdavQ

    And here's a pen where it's a bit more than the bare necessity and has some styling :

    Demo

提交回复
热议问题