Wednesday, February 19, 2014

Prevent table row onclick event to fire when clicking button inside the row

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
   <script type="text/javascript">
      function test(e) {
         alert('button');
         e.stopPropagation();
      }
   </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <table border="1" cellpadding="0" cellspacing="0">
          <tr onclick="javascript:alert('li')" style="cursor:pointer">
             <td>
             <input  type="button" onclick="test(event)" value="click me" />
             </td>
             <td>ll</td>
          </tr>
       </table>
    </div>
    </form>
</body>
</html>

No comments: