Thursday, 15 March 2012

javascript - jQuery: Event is attached to button, but fires at image element inside button in Chrome -



javascript - jQuery: Event is attached to button, but fires at image element inside button in Chrome -

i have such button in form:

<button class="delete-file-btn" "><img src="/img/del.png"/></button>

then attach event via jquery:

$('#form').on('click', 'button.delete-file-btn', function(e) { // code here });

when press button in crome, e.target points @ img element, not button. what's wrong event assignment? in ff works fine.

the e.target refers specific element clicked on, element targeted. event fired because target kid of element attached click on. utilize this refer element attached eventhandler on.

when seek illustration image e.target, in firefox.

i hope helps out!

javascript jquery

No comments:

Post a Comment