Yes there is.
Query the event.target and do an if conditional like so:
$("tr").click(function(e) {
// normalize e.target
if (!e) var e = window.event;
var tg = (window.event) ? e.srcElement : e.target;
if ( tg.nodeName != "INPUT" ) {
alert($(this).attr("id"));
} else {
//do something
}
});
if (!e) var e = window.event;
var tg = (window.event) ? e.srcElement : e.target;
if ( tg.nodeName != "INPUT" ) {
alert($(this).attr("id"));
} else {
//do something
}
});
Regards
Maurício
-----Mensagem Original-----De: AndykPara: jQuery (English)Enviada em: quarta-feira, 2 de dezembro de 2009 18:44Assunto: [jQuery] Ignoring click events in cellsI have a table, which contains some data aswell as a checkbox:
<tr id="14373">
<td><input type="checkbox"/></td>
<td>...</td>
<td>...</td>
</tr>
Each row contains an id, and I want to call a function based on the
click event:
$("tr").click(function() {
alert($(this).attr("id"));
});
However, checking/unchecking the checkbox in each row also triggers
the event. Is there anyway of preventing this?
No comments:
Post a Comment