bonjour, je voudrais une page html et il y a plusieurs bouton quand on clique sur l'un d'eux il y a un class div qui paraître et le background change et si on re clique le même bouton le background change à nouveau et le div se disparaître, mon problème est le background ne rechange plus, aidez-moi s'il vous plaît
mon code est comme ce-ci
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
78
79
80
<!DOCTYPE html>
<html>
 
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
 
  <link rel="stylesheet" href="./style.css">
  <link rel="stylesheet" href="./bootstrap/css/bootstrap.min.css">
  <style>
  </style>
</head>
<span for="" class="ton-code ton-code-devra-etre center-block text-center">
 
  <body id="body">
 
    <div class="col-md-4">
 
      <div id="hard-skills">
        <div class=" rectangle-1949">
        </div>
        <p>
          Ton code devra être fonctionnel, claire, performant, bien écrit et lisible.
        </p>
        Tu seras évalué sur 5 niveaux différents : mauvais, pauvre, juste, bon et
        excellent.
      </div>
 
      <div id= "agilePM">
        <div class=" rectangle-1949">
        </div>
 
        <p>
          On attendra de toi d’être ouvert, respectueux, courageux, rigoureux et
          concentré.
      </p>
      <p>
 
          Tu seras évalué sur 5 niveaux différents : mauvais, pauvre, juste, bon et
          excellent.
 
      </p>
      </div>
 
    </div>
    <div class="col-md-5">
 
      <button onclick="myFunction()">hard skills</button>
      <button onclick="agileFunction()">agile PM</button>
    </div>
    <script>
      var hardSkills = document.getElementById("hard-skills");
      var agilePM = document.getElementById("agilePM");
      var body = document.getElementById("body");
      function myFunction() {
        if (hardSkills.style.display === "none") {
          hardSkills.style.display = "block";
          agilePM.style.display = "none";
          body.style.background = rgba(0, 0, 0, 0.26);
        } else {
          body.style.background = "#E9EAEF";
          hardSkills.style.display = "none";
          agilePM.style.display = "none"; 
        }
      }
       function agileFunction() {
        if (agilePM.style.display === "none") {
          agilePM.style.display = "block";
          hardSkills.style.display = "none";
          body.style.background = rgba(0, 0, 0, 0.26);
        } else {
          body.style.background = "#E9EAEF";
          agilePM.style.display = "none";
          hardSkills.style.display = "none";
        }
      } 
    </script>
 
  </body>
 
</html>


mon css

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
body{
    background: #E9EAEF;
}
 
#hard-skills {
    display: none;
    background: #F2F2F7;
    border-radius: 20px;
    width: 355px !important;
    height: 285px;
    border-radius: 0px 0px 20px 20px;
  }
 
 
#agilePM {
    display: none;
    background: #F2F2F7;
    border-radius: 20px;
    width: 355px !important;
    height: 285px;
    border-radius: 0px 0px 20px 20px;
  }
 
 
/* Rectangle 1949 */
 
.rectangle-1949{
    /* margin-top: 12%; */
    /* position: absolute; */
    width: 340px;
    height: 13px;
    background: #FFCC00;
    transform: rotate(-180deg);
}