HTML Element Style How to - Handle click event on table cell








Question

We would like to know how to handle click event on table cell.

Answer


<!DOCTYPE html>
<html>
<head>
</head><!-- w  w  w.  j a  va  2 s.  c o  m-->
<body>
  <table border='1'>
    <th>
    <td onclick="window.location='http://www.google.com';"
      style='cursor: pointer;'>Hello</td>
    </th>
  </table>
</body>
</html>

The code above is rendered as follows: