I have a simple click handler
<h1 id="test">
$('#test').click( ev => {
var $test = $(this);
console.log($test.text());
})
but it does not work, $(this)
is not the emitter element. If I inspect this
I see a "window" (?) (??) (??!)
also, if I change my code to
var $test = $(ev.toElement);
it works perfectly.
how can this be? what is in my code that prevents jquery to correctly pass the element in this
?