user3238454
user3238454

Reputation: 74

How to get current element attributes from click event in Meteor?

lets say I have something like this:

'click #url_image': function(e) { 
  var className = $(this).attr("class");
  console.log(className);
}

"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?

Thanks

Upvotes: 1

Views: 3761

Answers (2)

martpie
martpie

Reputation: 6120

Or if you want a no-jQuery solution:

e.currentTarget.getAttribute('class');

Upvotes: 5

user1934044
user1934044

Reputation: 516

Try

$(e.currentTarget).attr("class");

Upvotes: 13

Related Questions