Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

I tried to do $('#MySelect').click(); using jQuery and tried document.getElementById('MySelect').click(); using pure javascript.

But the two don't fire the dropdown event that have the options of the select.

Ps: i have sure that selector $('#MySelect') exists.

like image 405
Paulo Roberto Rosa Avatar asked Nov 11 '13 18:11

Paulo Roberto Rosa


People also ask

How is the select event triggered when working for form fields?

The select event is sent to an element when the user makes a text selection inside it.

Which event is called on selection of an item from a dropdown list?

onChange:When a user selects a choice from a dropdown list, an event is triggered on item selection.

When user make a selection in the HTML select list event is raised?

When user makes a selection in the HTML select list, on cho vent is raised. 3. The property for an ID is referred to by. operator.

When user makes a selection in the HTML select list?

The <select> element is used to create a drop-down list. The <select> element is most often used in a form, to collect user input. The name attribute is needed to reference the form data after the form is submitted (if you omit the name attribute, no data from the drop-down list will be submitted).


1 Answers

are you looking for this

  document.getElementById("MySelect").selectedIndex=3;
like image 157
Vicky Gonsalves Avatar answered Sep 28 '22 12:09

Vicky Gonsalves