I have this jsbin ( prev answers didn't help much)
<span id="mySpan" > click here </span>
<br/>
<input id="myCb" type="checkbox"/>
i have a listener for checkbox
click which do Alert
...
However , clicking on the span
is triggering the click
event for the checkbox
.
I want to detect - who really made the checkBox execute the alert.
But !
I want : if first clicked the span , alert i was originally pressed by mySpan
else
if first clicked the checkbox , alert i was originally pressed by myCb
$("#mySpan").on('click',function (e)
{
$("#myCb").trigger('click');
});
$("#myCb").on('click',function (e)
{
doWork(e)
});
function doWork(e)
{
alert('i was originally pressed by '+$(e.delegateTarget).attr('id') );
}
p.s. i can use a global field or flag solution - which i DONT WANT.
i will be glad to have a "moving the data" through the e
param - solution.
thanks.:)
edit
jQuery does support moving data , but i cant write the right code