下拉列表流星的 onClick 事件 javascript
onClick event for dropdown list meteor javascript
有什么方法可以将点击事件添加到 Meteor 的下拉菜单中?我知道如何为按钮做这件事,但我找不到下拉菜单的文档。我的下拉菜单是:
<td>
<select id="orderStatus">
<option value="Submitted">Submitted</option>
<option value="Sent">Sent</option>
<option value="Complete">Complete</option>
</select>
</td>
我想要一个点击事件来提醒我 selected 的选项的值。比如我在下拉菜单中select"Sent",我想要一个alert"Sent".
谢谢。
您需要使用 change
事件:
Template.myTemplate.events({
"change #orderStatus": function(event, template){
var selectValue = template.$("#orderStatus").val();
console.log(selectValue);
}
});
有什么方法可以将点击事件添加到 Meteor 的下拉菜单中?我知道如何为按钮做这件事,但我找不到下拉菜单的文档。我的下拉菜单是:
<td>
<select id="orderStatus">
<option value="Submitted">Submitted</option>
<option value="Sent">Sent</option>
<option value="Complete">Complete</option>
</select>
</td>
我想要一个点击事件来提醒我 selected 的选项的值。比如我在下拉菜单中select"Sent",我想要一个alert"Sent".
谢谢。
您需要使用 change
事件:
Template.myTemplate.events({
"change #orderStatus": function(event, template){
var selectValue = template.$("#orderStatus").val();
console.log(selectValue);
}
});