如何从 Meteor 中的单击事件获取当前元素属性? [英] How to get current element attributes from click event in Meteor?
本文介绍了如何从 Meteor 中的单击事件获取当前元素属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有这样的事情:
'click #url_image': function(e) {
var className = $(this).attr("class");
console.log(className);
}
meteor 中的this"是当前模板的上下文,而不是被点击的实际项目.我如何从实际的点击事件中获取类或其他属性,在这种情况下是 #url_image 的类?
"this" in meteor is the context of the current template, not the actual item which was clicked. how could I get the class or other attribute from the actual click event, in this case the class of #url_image?
谢谢
推荐答案
尝试
$(e.currentTarget).attr("class");
这篇关于如何从 Meteor 中的单击事件获取当前元素属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文