Zze Zze - 1 year ago 70
HTML Question

Event not triggering in Chrome

I am having an issue where clicking

does not trigger the event handler. I think the issue is that the event is not propagating down to the
of the
element? The annoyance is that this snippet works in; IE8 and above, and Firefox, but does not work in Chrome?

var target = 1;


function TargetClicked(ele)
if($(ele).prop("id") == ("target" + target))
$("body").append("You clicked >> #" + $(ele).prop("id") + "<br>");

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p id="target1">Click here first</p>
<select id="target2">
<option id="target3">target 3</option>

This is from a very large project, so I would like to try and find a
javascript / JQuery
fix or workaround for this issue if possible as editing the
is not feasible.

Zze Zze
Answer Source

This is a known Chrome bug


I fixed this issue by checking to see what type of element was being targeted, and then in the case of an <option>, I instead applied a change event instead of a click event.

The caveat is that this event has to go on the <select> element, not the <option> element, which in my case was not ideal.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download