Duplication de table HTML via JavaScript
Bonjour à tous,j'entre dans le vif du sujet.
Je ne sais pas pourquoi quand j'essaie de cloner une table de HTML,il n'affiche pas.Pourtant le même code marche avec l'éditeur de W3C school.
J'ignore c'est le problème de l'eclipse ou celui de navigateur :?
table.html
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title >Dublication de la table</title>
<script type="text/javascript" src="table.js"></script>
</head>
<body>
<form>
<table border="1">
<tr>
<td>L1C1</td>
<td>L1C2</td>
</tr>
<tr>
<td>L2C1</td>
<td>L2C2</td>
</tr>
<tr>
<td>L3C1</td>
<td>L3C2</td>
</tr>
<tr>
<td>L4C1</td>
<td>L4C2</td>
</tr>
<tr>
<td>L5C1</td>
<td>L5C2</td>
</tr>
</table>
<input type="submit" value="Dubliquer">
</form>
</body>
</html> |
table.js
Code:
1 2 3
| var table = document.getElementsByTagName("table")[0];
var newtable = table.cloneNode(true);
table.parentNode.appendChild(newtable); |