onClick event for dropdown list meteor javascript

1.8k views Asked by At

is there a way I can add a click event to a dropdown menu in Meteor? I know how to do it for buttons, but I couldn't find documentation for dropdown menus. My dropdown menu is:

<td>
    <select id="orderStatus">
        <option value="Submitted">Submitted</option>
        <option value="Sent">Sent</option>
        <option value="Complete">Complete</option>
    </select>
</td>

I want an click event that alerts with the value of the option that i selected. For example, I select "Sent" in the dropdown menu, I want an alert "Sent".

Thank you.

1

There are 1 answers

0
saimeunt On BEST ANSWER

You need to use a change event :

Template.myTemplate.events({
  "change #orderStatus": function(event, template){
    var selectValue = template.$("#orderStatus").val();
    console.log(selectValue);
  }
});