I have an entire TD set up to be clickable to minimize and maximize it. However, I want to make it so that if a certain part of the TD is clicked, it doesn’t min/max it, but executes some other code. After reading around this site and google I figured out I would need to find the event’s target. I took that code from another question on stackoverflow and it works perfectly in Chrome, but the JS crashes in Firefox.
Here is where it crashes:
$(function()
{
$('.clickable').live('click', function()
{
alert('click');
//Figuring out where a user clicked
var targ;
var e;
if (!e)
e = window.event;
if (e.target)
targ = e.target;
else if (e.srcElement)
targ = e.srcElement;
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode;
alert('after');
});
return false;
});
In both cases, the alert ‘click’ is displayed, but only in Chrome is ‘after’ displayed. Any help?
Remove
and add the event
eas function parameter:Also see this jsfiddle.