Bonjour / soir,
Je souhaite effectuer un comptage d'un ensemble d’éléments enfant pour chaque ligne d'une table (et ne sais pas comment m'y prendre)
le concept :
et j’aimerais également pouvoir connaitre le 1er élément de chaque TD..?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 <style> table { border-spacing: 0px; border:1px solid #ccd7c4 !important; border-collapse:collapse; border-spacing:2px; margin-top:0px; margin-bottom:0px; margin-left:auto !important; margin-right:auto !important; font-size:11px; max-height: 650px; overflow-y: auto; } tr, td { border:1px solid #ccd7c4 !important; } </style> <script> function mafunctionJS() { var table = document.getElementById('tableau'); var nbr_lignes = table.getElementsByTagName('TR').length; var Elmnts = table.getElementsByTagName('SPAN'); var total = document.getElementById('total'); for (var i = 0; i < nbr_lignes.length; i++) { total.innerHTML = Elmnts.length; } } </script> <table id="tableau" onmouseOver="mafunctionJS()" > <tr > <td id="compte"> <span></span> <span></span> <span></span> <span id="total"> </span> </td> </tr> <tr> <td id="compte"> <span></span> <span></span> <span id="total"> </span> </td> </tr> <tr> <td cass="compte"> <span></span> <span id="total"> </span> </td> </tr> </table>
Des pistes ?
Partager