Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <table>
    <tbody>
      <tr>
        <td>0x0</td>
        <td>0x1</td>
      </tr>
      <tr>
        <td>1x0</td>
        <td>1x1</td>
      </tr>
    </tbody>
  </table>
  <script>
    (function() {
      function handlerAsignment()
      {
        var trs = document.getElementsByTagName("tr");
        var tds;
        var forEach = Array.prototype.forEach;
  
        forEach.call(trs, function(tr, trIndex) {
          forEach.call(tr.getElementsByTagName("td"), function(td, tdIndex) {
            td.onclick = function() {
              atack(trIndex, tdIndex);
            };
          });
        });
      }
      
      function atack(tr, td) {
        alert("Attack " + tr + "x" + td);
      }
      
      handlerAsignment();
    })();
  </script>
</body>
</html>
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers