After reading some questions/answers about this subject I have tried to make it works for me but I can't.
The story line is that I have X elements (so it means no ID just class) and I want to change the background when I click in one.
So with JS I did:
'click .switch' (event) {
event.toElement.closest("li").css('background-color','black');
if(this.stateMachine == 'running'){
Meteor.call("switch", this.nameMachine);
}
},
to get the container (here a <li class="liMachine switch">) but I have this error:
event.toElement.closest(...).css is not a function
Despite the event.toElement.closest returns the right element:

So what am I doing wrong ?
event.toElementto$(this)or$(event.target). Preferably the formerclickin your selector? That's not valid HTML, unless you're using some odd library you haven't mentioned$(event.target)!!