Bonjour,
J’aurais besoin de votre aide.Je souhaite affiché le contenu du div et masqué tous les autres div lorsque je click sur afficher.
Voici le code :

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
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
81
82
83
84
<!doctype html>
<html lang="fr">
<head>
  <meta charset="utf-8">
  <title>Afficher / Masquer</title>
</head>
<body>
 
	<script>
	function afficher_cacher(id)
	{
   if(document.getElementById(id).style.display == "block"){
		document.getElementById(id).style.display = "none";
		document.getElementById('bouton_'+id).innerHTML='Afficher';
	}
  else{
		document.getElementById(id).style.display = "block";
		document.getElementById('bouton_'+id).innerHTML='Masquer';
	}
}
 
	</script>
 
	<style>
	#texte{
		display:none;		
	}
	#texte1{
		display:none;		
	}
	#texte2{
		display:none;		
	}
	#texte3{
		display:none;		
	}
 
 
	</style>
 
	<div id="bouton_texte" onclick="javascript:afficher_cacher('texte');">Afficher</div>
		<div id="texte">
			<table >
				<td>val 1</td>
				<td>val 2</td>
				<td>val 3</td>
				<td>val 4</td>
			</table>	
		</div>
 
	<div id="bouton_texte" onclick="javascript:afficher_cacher('texte');" >Afficher</div>
		<div id="texte1">
			<table >
				<td>val 1</td>
				<td>val 2</td>
				<td>val 3</td>
				<td>val 4</td>
			</table>
		</div>
 
	<div  id="bouton_texte" onclick="javascript:afficher_cacher('texte');" >Afficher</div>
		<div id="texte2">
			<table >
				<td>val 1</td>
				<td>val 2</td>
				<td>val 3</td>
				<td>val 4</td>
			</table>
		</div>
 
 
	<div  id="bouton_texte" onclick="javascript:afficher_cacher('texte');" >Afficher</div>
		<div id="texte3">
			<table >
				<td>val 1</td>
				<td>val 2</td>
				<td>val 3</td>
				<td>val 4</td>
			</table>
		</div>
 
 
</body>
</html>
Mon souci c'est que lorque je click sur le deuxieme,troisieme ou quatrieme bouton c'est à chaque fois le premier div qui s'affiche et pas celui sur lequel je click.
Je sais pas si mon script est correct.
Merci de votre aide