monda
monda

Reputation: 3915

MeteorJS: How to get clicked element

I'm trying to get the clicked element so that I can add class. Does Meteor provides any way to get the current element like jQuery $ (this)

Template.retraining.events({
    'click .myclass': function (event) {
        //Get the clicked element like $(this) in jQuery
        $().addClass('existing-col');
    }
});

Upvotes: 3

Views: 213

Answers (2)

sravanthi
sravanthi

Reputation: 247

From this you can get textbox value with one button click event.

Try this:

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

Upvotes: 1

Tushar
Tushar

Reputation: 87203

To get the element on which the event occurred, use event object.

event.target

As you've jQuery included, you can wrap the element in jQuery to use jQuery methods on it.

$(event.target)

You can see this in Meteor Tutorial

event.target

Upvotes: 5

Related Questions