I have a table like this:
<table>
<tr onclick="window.location='foo.html'">
<td>Data 1</td>
<td>Data 2</td>
<td><a href="bar.html">link</a></td>
</tr>
</table>
When I try to click the link
text, I get sent to foo.html
. I'd like to go to bar.html
instead. Is there a way to make sure that the <a>
gets the click event first?
Or do I have to change my onclick
handler to be on each of the <td>
elements except for the final one containing the link?
答案 0 :(得分:2)
答案 1 :(得分:1)
您可以使用onclick作为锚标记:
<a href="#" onclick="window.location='bar.html'">link</a>