[jQuery] Help with stopping event propagation.
(I saw another email come through but not this one and it's been about
30 minutes since I originally sent. Apologies if you see this twice.)
Hi.
I am applying a click() event to a <tr> but I only want the event to
fire if someone clicks on empty space or plain text. With the help of
the IRC channel I've only been able to get the click event to stop
working on a form element but nothing else.
Anyone have any ideas?
Here's my JS:
$('tr.customer').click( function(e) {
if($(e.target).is(":input")) return; // this works
if($(e.target).is(":input, a")) return; // this doesn't work
if($(e.target).is("a")) return; // this doesn't work
if($(e.target).is(":a")) return; // this doesn't work
// get the customer's id
customer_id = $(this).attr('customer_id');
alert('you clicked me! my number is '+customer_id+'!');
});
Here's my HTML:
<tr class="customer is_admin" customer_id="1">
<td class="checkbox">
<input type="checkbox" name="customer_id[]" value="1"/>
</td>
<td class="name">
<a href="customers_add.php?customer_id=1">Chris</a>
</td>
<td class="delete">
<a href="javascript:alert('not yet!')">
<img src="../lib/admin/img/delete.png"/>
</a>
</td>
</tr>
Thanks!
Chris.