Javascript 外部事件比内部事件上升

Javascript 外部事件比内部事件上升,javascript,html-table,Javascript,Html Table,我创建了以下html: <table> <tr> <td onclick="window.location.href = 'Add.html'"> 1 <div onclick="window.location.href = 'Update.html'"> Update me &

我创建了以下html:

<table>
       <tr>
           <td onclick="window.location.href = 'Add.html'">
                1
                <div onclick="window.location.href = 'Update.html'">
                    Update me
                </div>
           </td>
       </tr>
</table>

1.
更新我
当我单击td时,它重定向
Add.html
。没关系。但当我单击div时,它也重定向到
Add.html
页面。我想重定向到
Update.html
页面

<table>
       <tr>
           <td onclick="loadUrl(event,'add.html')">
                Add me
                <div onclick="loadUrl(event,'update.html')">
                    Update me
                </div>
           </td>
       </tr>
</table>
像这样->可能重复的
function loadUrl(ev,url)
{
    var e = ev || window.event;
    alert(url);

    // do whatever you want


    e.cancelBubble = true;
    if (e.stopPropagation) e.stopPropagation();
}