I have a table and in each row is an an anchor element. How w开发者_JS百科ould I go about triggering the click of the href if the parent row is clicked anywhere in the row?
Assuming you mean a table row, the you would add a click handler to the row that simply clicked the child a
tag:
$("tr").click(function() {
$(this).children("td > a").click();
return false; // Prevent event propagation and infinite loops
});
EDIT: Thanks to Tatu for reminding me about event propagation
精彩评论