I have a code snippet
$(document).on("click", "div[data-role=button]", myfunc);
function myfunc(e){
alert(event.target);
alert(e.target);
alert(event.currentTarget);
alert(e.currentTarget);
}
Each of them give different outputs when i click on the element.
e is of type object
event is oftype MouseEvent
The e.currentTarget seems to give the correct answer.
My question is if i decided to add another parameter to my handler, how will i get to access the "e", parameter which gives the right answer.
EDIT:
I want to do
function myfunc(e,str){
}
How can i access e inside my function and how do i pass the two arguments?
EDIT 2 I found another interesting thing,
this
this correctly gives the target, even though i expected it to give the document any idea why?
myfunc(e, x)? Obviously that wouldn't be an issue. Can you show example code for what you mean?strsupposed to be? It isn't going to get passed by the click event firing.