Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Jquery $(this) in Meteor

How can I use the this function in meteor? for example, I want to be able to click on any given

element and find out what its class is. Also, how can I get information on the item that I click on with Meteor?

like image 390
illathruz Avatar asked Aug 02 '12 03:08

illathruz


1 Answers

Let's say somewhere in the code you have a template handling events:

Template.tmpl_name.events = {
  'click #logo': function (e) {
    // Instead of using $(this), you can do:
    var $this = $(e.target);
    // Your usual code here, e.g.:
    console.log($this.attr('href'));
  }
};
like image 189
nsmeta Avatar answered Sep 20 '22 15:09

nsmeta