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.10.1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<p>Every two seconds, I'll add a row to this table (up to 20 rows). Click as things continue to get added...</p>
<table id="myTable"><tbody></tbody></table>
  <script>
    (function() {
      $("#myTable").on("click", "tr", function() {
          alert("You clicked row #" + $(this).index());
      });
      addRow();
      
      function addRow() {
        var tbody = $("#myTable tbody");
        tbody.append("<tr><td>Hi there, click me</td></tr>");
        if (tbody.children().length < 20) {
          setTimeout(addRow, 2000);
        }
      }
    })();
  </script>
</body>
</html>
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers