0

I created the following html:

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

When I click td, it redirect Add.html. It is OK. But when I click div, it also redirect to Add.html page. I would like to redirect to Update.html page.

Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126
zanhtet
  • 2,024
  • 7
  • 33
  • 56

1 Answers1

2

DEMO

<table>
       <tr>
           <td onclick="loadUrl(event,'add.html')">
                Add me
                <div onclick="loadUrl(event,'update.html')">
                    Update me
                </div>
           </td>
       </tr>
</table>

JavaScript

function loadUrl(ev,url)
{
    var e = ev || window.event;
    alert(url);

    // do whatever you want


    e.cancelBubble = true;
    if (e.stopPropagation) e.stopPropagation();
}
Voonic
  • 4,419
  • 3
  • 26
  • 56