我在jQuery数据函数中遇到了一些麻烦。jquery data()不起作用
$(e.target).data(“unitId”)未定义。
我一直在尝试解决这一段时间,但无法找到我的代码有什么问题。
有没有人看到这里有什么问题?
var SomeView = Backbone.View.extend({
el: '#sidebar',
events: {
"click .link-unit": "route"
},
initialize: function(){
this.render();
},
render: function(){
this.$el.html('<div class="link-unit" data-unitId="some data">some text</div>');
},
route: function(e){
console.log($(e.target).data('unitId'));
},
});
? – Alex
你能提供相关的标记吗? – PeterKA