How to trigger the HTML Select onClick event (activates select dropdown with options)

前端 未结 2 2055
不知归路
不知归路 2020-12-16 05:38

I want to know how to trigger the onClick event of any select(html combobox element).

I tried to do $(\'#MySelect\').click();

相关标签:
2条回答
  • 2020-12-16 06:06

    are you looking for this

      document.getElementById("MySelect").selectedIndex=3;
    
    0 讨论(0)
  • 2020-12-16 06:18

    Programatically triggering a click event will only run the defined click handler for that element. As you say in the comments, you have no such method defined, therefore no action will take place.

    0 讨论(0)
提交回复
热议问题