Javascript MeteorJS:如何获得单击元素

Javascript MeteorJS:如何获得单击元素,javascript,jquery,meteor,Javascript,Jquery,Meteor,我正在尝试获取单击的元素,以便添加类。Meteor是否提供了获取当前元素(如jQuery$)的方法 要获取发生事件的元素,请使用eventobject event.target 在包含jQuery之后,可以将元素包装在jQuery中,以便对其使用jQuery方法 $(event.target) 你可以从中看到这一点 从中,您可以通过单击按钮事件获得文本框值 试试这个: Template.retraining.events({ 'click .myclass':function(e,t){

我正在尝试获取单击的元素,以便添加类。Meteor是否提供了获取当前元素(如jQuery$)的方法


要获取发生事件的元素,请使用
event
object

event.target
在包含jQuery之后,可以将元素包装在jQuery中,以便对其使用jQuery方法

$(event.target)
你可以从中看到这一点


从中,您可以通过单击按钮事件获得文本框值

试试这个:

Template.retraining.events({
'click .myclass':function(e,t){
 var val = t.find(".classname").value;
}
Template.retraining.events({
'click .myclass':function(e,t){
 var val = t.find(".classname").value;
}