Javascript 如何获取组合框上上次更改的选项的值
纯jQuery版本:Javascript 如何获取组合框上上次更改的选项的值,javascript,jquery,html,backbone.js,Javascript,Jquery,Html,Backbone.js,纯jQuery版本: $('select#register-type').live('change', function () { console.log($(this).val()); }); 主干视图委派事件版本: App.Views.register = new (Backbone.View.extend({ tagName: 'section', id: 'content', template: _.template($('script.register').html
$('select#register-type').live('change', function () {
console.log($(this).val());
});
主干视图委派事件版本:
App.Views.register = new (Backbone.View.extend({
tagName: 'section',
id: 'content',
template: _.template($('script.register').html()),
render: function () {
this.$el.html(this.template);
return this;
},
events: {
'change select#register-type': 'type'
},
type: function (event) {
// i want to console.log the current option selected...
}
}));
我怎样才能做到这一点?似乎我不能像jquery版本那样使用$(this),这是指注册视图对象…使用
事件。目标
type: function (event) {
$(event.target).find('option:selected').val();
**OR**
$(event.target).val();
}
'选择#寄存器类型'