title: Remove generated fields javascript
body: <p>I have a problem removing fields with a js function. First, I generate this as much a as I have entries in the database table:</p>
  
  <pre><code>function queryComposant($param) {
      $query = "SELECT nom_" . $param . " FROM " . $param . ";";
      $result = connectdb()-&gt;query($query)or die("Err " . $query);
      $resultat = $result-&gt;fetch(PDO::FETCH_OBJ);
      echo '&lt;table border = "1" id="table' . $param . '"&gt;';
  
      foreach ($resultat as $value) {
  
      }
  
      while ($resultat = $result-&gt;fetch(PDO::FETCH_OBJ)) {
  
          echo '&lt;tr&gt;'
          . '&lt;form action="' . $param . 'Delete.php"  method="post"&gt;';
          $n = "nom_" . $param;
          $nom = $resultat-&gt;$n;
          echo '&lt;td&gt;' . $nom . '&lt;/td&gt;'
          . '&lt;input id="' . $param . 'delete" type="hidden" name="delete" value="'.$nom.'"    /&gt;'
          . '&lt;td&gt;&lt;input type="button"  onclick="remove();" value="Supprimer" /&gt;&lt;/td&gt;'
          . '&lt;/form&gt;'
          . '&lt;/tr&gt;';
      }
  
      echo '&lt;/table&gt;';
  }
  </code></pre>
  
  <p>and I'd like to remove the entire <code>tr</code> in the table each time I click on the button "Supprimer".</p>
  
  <pre><code>function remove(){
      $().live('click',function(){
          var whichtr = $(this).parent().parent();
          whichtr.remove(); 
      });
  }
  </code></pre>
  
  <p>what am i doing wrong? I used <code>$(this).parent().parent();</code> to go from <code>button</code> to <code>td</code> and from <code>td</code> to <code>tr</code> and then try remove it but the function only removes the button.</p>
  
  <p>I also tried this, with no more success:</p>
  
  <pre><code>function remove(){
      $().live('click',function(){
          var whichtr = $(this).closest("tr");
          whichtr.remove(); 
      });
  }
  </code></pre>