Forum » Programiranje » JavaScript - removeChild problem
JavaScript - removeChild problem
nemonemo ::
Pozdravljeni.
Sem bolj kot ne začetnik v Javascriptu in imam težavo pri izvajanju tega ukaza. Prevajalnik mi namreč javi napako: Napaka: uncaught exception: [Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NS_ERROR_DOM_NOT_FOUND_ERR)" location: "http://localhost/test1.html Line: 10"]
Sem bolj kot ne začetnik v Javascriptu in imam težavo pri izvajanju tega ukaza. Prevajalnik mi namreč javi napako: Napaka: uncaught exception: [Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NS_ERROR_DOM_NOT_FOUND_ERR)" location: "http://localhost/test1.html Line: 10"]
<head>
<script language="javascript">
function odstrani()
{
var tabela=document.getElementById('tabela');
var vrstica=document.getElementsByName("vrstica")[0];
tabela.removeChild(vrstica);
}
</script>
</head>
<body>
<input type="button" value="odstrani vrstico" name="odstrani" onClick="odstrani()"/>
<table border="1" id="tabela">
<tr name="vrstica"><td>test</td></tr>
</table>
</body>
LeQuack ::
Takole:
<head>
<script language="javascript">
function odstrani()
{
var tabela=document.getElementById('tabela');
var vrstica=document.getElementsByName("vrstica")[0];
tabela.deleteRow(vrstica);
}
</script>
</head>
<body>
<input type="button" value="odstrani vrstico" name="odstrani" onClick="odstrani()"/>
<table border="1" id="tabela">
<tr name="vrstica"><td>test</td></tr>
</table>
</body>
Quack !
nemonemo ::
funkcija deleteRow mi izbriše vedno prvo vrstico v tabeli. obstaja način da bi mi izbrisala vrstico z določenim imenom?
<head>
<script language="javascript">
function odstrani()
{
var tabela=document.getElementById('tabela');
var vrstica=document.getElementsByName("vrstica")[0];
tabela.deleteRow(vrstica);
}
</script>
</head>
<body>
<input type="button" value="odstrani vrstico" name="odstrani" onClick="odstrani()"/>
<table border="1" id="tabela">
<tr name="1"><td>1</td></tr>
<tr name="2"><td>2</td></tr>
<tr name="3"><td>3</td></tr>
<tr name="vrstica"><td>test</td></tr>
</table>
</body>
Zgodovina sprememb…
- spremenil: nemonemo ()
Lion29 ::
name ni pravi atribut za TR
z jQuery-jem bi pa to zelo hitro uredil
z jQuery-jem bi pa to zelo hitro uredil
$('#tabela tr[name="2"]').remove(); Founder and CTO @ Article-Factory.ai
Vredno ogleda ...
| Tema | Ogledi | Zadnje sporočilo | |
|---|---|---|---|
| Tema | Ogledi | Zadnje sporočilo | |
| » | JqueryOddelek: Izdelava spletišč | 1955 (1679) | mk818764 |
| » | Potrebujem javascript pomočOddelek: Programiranje | 1323 (1073) | no1pheeew |
| » | [PHP/JavaScript] tic tac toeOddelek: Programiranje | 1892 (1625) | illion |
| » | JavaScript offsetTop in brskalnikiOddelek: Izdelava spletišč | 1107 (1039) | shorvat |
| » | JavaScriptOddelek: Izdelava spletišč | 1556 (1401) | Gandalfar |