Bonjour,

j'ai une petite question à propos d'une fonction que je viens de faire pour masquer/afficher les lignes d'un tableau.

En fait la fonction jquery fonctionne mais je dois faire des double click pour afficher masquer mes lignes ^^

voici le code :

HTML
Code HTML : 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
 
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>repl.it</title>
    <link href="index.css" rel="stylesheet" type="text/css" />
    <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js"></script>
    <script src="script.js"></script>
    </head>
  <body>
      <div id="cont">
<div id="tab">
<table border=1 style="border-collapse:collapse">
    <tr>
        <th colspan=7>FO</th>
    </tr>
    <tr>
        <th >A</th>
        <th >B</th> 
        <th >C</th> 
        <th >D</th> 
        <th >E</th>
    </tr>  
    <tr class="disable">
        <td >1</td>
        <td >1</td>
        <td >1</td>
        <td >1</td>
        <td >disable</td>
    </tr>
    <tr class="enable">
        <td >1</td>
        <td >1</td>
        <td >1</td>
        <td >1</td>
        <td >enable</td>
    </tr>
    <tr>
        <td colspan=7>FOVIP</td>
    </tr>
    <tr>
        <th >A</th>
        <th >B</th> 
        <th >C</th> 
        <th >D</th> 
        <th >E</th>
    </tr>
    <tr class="disable">
        <td >8</td>
        <td >1</td>
        <td >1</td>
        <td >1</td>
        <td class="disable" >disable</td>
    </tr>
    <tr class="enable">
        <td >1</td>
        <td >1</td>
        <td >2</td>
        <td >1</td>
        <td >enable</td>
    </tr>
</table>
</div>
<div id="button">
<span id="affiche">
    <button onclick="showhide()">clique ici<button>
 </span>
<span id="refresh">
</span>
</div>
 
</div>
 
  </body>
</html>

script javascript :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
function showhide(){
     $("#affiche").click(function(){
            $(".disable").toggle();
            })
}
vu la fonction jquery que j'appelle, je ne comprend pas pourquoi je dois faire des double click ^^

merci à vous