Home   FORUM   Toplista   HTML   CSS   JavaScript   PHP   DIZAJN   SEO   Mapa
KONTAKT
izuzetan[at]gmail.com






TOP LISTA SAJTOVA

DeleteRow(), deleteCell() i rowIndex

deleteRow( ), deleteCell( ) i rowIndex - deleteRow briše red u tabeli, a deleteCell briše ćeliju. RowIndex vraća indeks reda u tabeli. Analogno tome cellIndex vraća indeks ćelije u redu. Evo primera:

<html><head>
<script type="text/javascript">
function brisiCeliju(){
     document.getElementById("tr2").deleteCell(1);
}
function brisiRed(r){
      i = r.parentNode.parentNode.rowIndex
     document.getElementById("tabla").deleteRow(i);
}
</script></head><body>
<table id="tabla" border="1">
     <tr id="tr1">
          <td>Red 1</td><td>Red 1</td>
          <td><input type="button" value="Izbrisi red" onclick=brisiRed(this)></td>
     </tr><tr id="tr2">
          <td>Red 2</td><td>Ova celija se brise</td>
          <td><input type="button" value="Izbrisi celiju" onclick=brisiCeliju()></td>
</tr>
</table></body></html>

Copyright © 2010 BUbaj. Powered By bubaj.com
JavaScript    Sintaksa    Osnovne funkcije    Kontrolne strukture    Dogadjaji    Browser funkcije    HTML DOM objekti    Tabele    JS i CSS    CANVAS