Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>Test Page</title>
<style>
  body {
    font-family: sans-serif;
  }
  table, td {
    border-collapse: collapse;
    border: 1px solid black;
  }
</style>
</head>
<body>
  <table>
    <tbody id="target">
    <tr>
      <td class="one">This is one in row 0</td>
      <td class="two">This is two in row 0</td>
      <td class="three">This is three in row 0</td>
    </tr>
    <tr>
      <td class="one">This is one in row 1</td>
      <td class="two">This is two in row 1</td>
      <td class="three">This is three in row 1</td>
    </tr>
    <tr>
      <td class="one">This is one in row 2</td>
      <td class="two">This is two in row 2</td>
      <td class="three">This is three in row 2</td>
    </tr>
    </tbody>
  </table>
</body>
</html>
 
jQuery(function($) {
  
  // Put the handler on the tbody
  $("#target").click(clickHandler);
  
  function clickHandler(e) {
    var td = $(e.target).closest('tr').children('td').first();
    display("The text of the first <code>td</code> in that row is: " + td.text());
  }
  
  function display(msg) {
    $("<p>").html(String(msg)).appendTo(document.body);
  }
  
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers