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,753
  • 72
  • 57
  • 129
zanhtet
  • 2,040
  • 7
  • 33
  • 58

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,667
  • 3
  • 27
  • 58