Bonjour,
voila j'ai un probleme avec ce code :
<html>
<head>
<script>
function test1() {
document.getElementById('div1').style.display='block'
document.getElementById('div2').style.display='none'
document.getElementById('div3').style.display='none'
document.getElementById('div4').style.display='none'
document.getElementById('div5').style.display='none'
document.getElementById('div6').style.display='none'
document.getElementById('div7').style.display='none'
document.getElementById('div8').style.display='none'
document.getElementById('div9').style.display='none'
document.getElementById('div10').style.display='none'
document.getElementById('div11').style.display='none'
document.getElementById('div12').style.display='none'
}
function test2() {
document.getElementById('div2').style.display='block'
document.getElementById('div1').style.display='none'
document.getElementById('div3').style.display='none'
document.getElementById('div4').style.display='none'
document.getElementById('div5').style.display='none'
document.getElementById('div6').style.display='none'
document.getElementById('div7').style.display='none'
document.getElementById('div8').style.display='none'
document.getElementById('div9').style.display='none'
document.getElementById('div10').style.display='none'
document.getElementById('div11').style.display='none'
document.getElementById('div12').style.display='none'
}
function test3() {
document.getElementById('div3').style.display='block'
document.getElementById('div1').style.display='none'
document.getElementById('div2').style.display='none'
document.getElementById('div4').style.display='none'
document.getElementById('div5').style.display='none'
document.getElementById('div6').style.display='none'
document.getElementById('div7').style.display='none'
document.getElementById('div8').style.display='none'
document.getElementById('div9').style.display='none'
document.getElementById('div10').style.display='none'
document.getElementById('div11').style.display='none'
document.getElementById('div12').style.display='none'
}
function test4() {
document.getElementById('div4').style.display='block'
document.getElementById('div1').style.display='none'
document.getElementById('div3').style.display='none'
document.getElementById('div2').style.display='none'
document.getElementById('div5').style.display='none'
document.getElementById('div6').style.display='none'
document.getElementById('div7').style.display='none'
document.getElementById('div8').style.display='none'
document.getElementById('div9').style.display='none'
document.getElementById('div10').style.display='none'
document.getElementById('div11').style.display='none'
document.getElementById('div12').style.display='none'
}
function test5() {
document.getElementById('div5').style.display='block'
document.getElementById('div1').style.display='none'
document.getElementById('div3').style.display='none'
document.getElementById('div2').style.display='none'
document.getElementById('div4').style.display='none'
document.getElementById('div6').style.display='none'
document.getElementById('div7').style.display='none'
document.getElementById('div8').style.display='none'
document.getElementById('div9').style.display='none'
document.getElementById('div10').style.display='none'
document.getElementById('div11').style.display='none'
document.getElementById('div12').style.display='none'
}
function test6() {
document.getElementById('div6').style.display='block'
document.getElementById('div1').style.display='none'
document.getElementById('div3').style.display='none'
document.getElementById('div2').style.display='none'
document.getElementById('div5').style.display='none'
document.getElementById('div4').style.display='none'
document.getElementById('div7').style.display='none'
document.getElementById('div8').style.display='none'
document.getElementById('div9').style.display='none'
document.getElementById('div10').style.display='none'
document.getElementById('div11').style.display='none'
document.getElementById('div12').style.display='none'
}
function test7() {
document.getElementById('div7').style.display='block'
document.getElementById('div1').style.display='none'
document.getElementById('div3').style.display='none'
document.getElementById('div2').style.display='none'
document.getElementById('div5').style.display='none'
document.getElementById('div6').style.display='none'
document.getElementById('div4').style.display='none'
document.getElementById('div8').style.display='none'
document.getElementById('div9').style.display='none'
document.getElementById('div10').style.display='none'
document.getElementById('div11').style.display='none'
document.getElementById('div12').style.display='none'
}
function test8() {
document.getElementById('div8').style.display='block'
document.getElementById('div1').style.display='none'
document.getElementById('div3').style.display='none'
document.getElementById('div2').style.display='none'
document.getElementById('div5').style.display='none'
document.getElementById('div6').style.display='none'
document.getElementById('div7').style.display='none'
document.getElementById('div4').style.display='none'
document.getElementById('div9').style.display='none'
document.getElementById('div10').style.display='none'
document.getElementById('div11').style.display='none'
document.getElementById('div12').style.display='none'
}
function test9() {
document.getElementById('div9').style.display='block'
document.getElementById('div1').style.display='none'
document.getElementById('div3').style.display='none'
document.getElementById('div2').style.display='none'
document.getElementById('div5').style.display='none'
document.getElementById('div6').style.display='none'
document.getElementById('div7').style.display='none'
document.getElementById('div8').style.display='none'
document.getElementById('div4').style.display='none'
document.getElementById('div10').style.display='none'
document.getElementById('div11').style.display='none'
document.getElementById('div12').style.display='none'
}
function test10() {
document.getElementById('div10').style.display='block'
document.getElementById('div1').style.display='none'
document.getElementById('div3').style.display='none'
document.getElementById('div2').style.display='none'
document.getElementById('div5').style.display='none'
document.getElementById('div6').style.display='none'
document.getElementById('div7').style.display='none'
document.getElementById('div8').style.display='none'
document.getElementById('div9').style.display='none'
document.getElementById('div4').style.display='none'
document.getElementById('div11').style.display='none'
document.getElementById('div12').style.display='none'
}
function test11() {
document.getElementById('div11').style.display='block'
document.getElementById('div1').style.display='none'
document.getElementById('div3').style.display='none'
document.getElementById('div2').style.display='none'
document.getElementById('div5').style.display='none'
document.getElementById('div6').style.display='none'
document.getElementById('div7').style.display='none'
document.getElementById('div8').style.display='none'
document.getElementById('div9').style.display='none'
document.getElementById('div10').style.display='none'
document.getElementById('div4').style.display='none'
document.getElementById('div12').style.display='none'
}
function test12() {
document.getElementById('div12').style.display='block'
document.getElementById('div1').style.display='none'
document.getElementById('div3').style.display='none'
document.getElementById('div2').style.display='none'
document.getElementById('div5').style.display='none'
document.getElementById('div6').style.display='none'
document.getElementById('div7').style.display='none'
document.getElementById('div8').style.display='none'
document.getElementById('div9').style.display='none'
document.getElementById('div10').style.display='none'
document.getElementById('div11').style.display='none'
document.getElementById('div4').style.display='none'
}
</script>
<div style="position:absolute"><a href="#" onclick="test1()">menu 1</a></div>
<div style="position:absolute;margin-left:100px"><a href="#"onclick="test2()">menu 2</a></div>
<div style="position:absolute;margin-left:200px"><a href="#"onclick="test3()">menu 3</a></div>
<div style="position:absolute;margin-left:300px"><a href="#"onclick="test4()">menu 4</a></div>
<div style="position:absolute;margin-left:400px"><a href="#"onclick="test5()">menu 5</a></div>
<div style="position:absolute;margin-left:500px"><a href="#"onclick="test6()">menu 6</a></div>
<div style="position:absolute;margin-left:600px"><a href="#"onclick="test7()">menu 7</a></div>
<div style="position:absolute;margin-left:700px"><a href="#"onclick="test8()">menu 8</a></div>
<div style="position:absolute;margin-left:800px"><a href="#"onclick="test9()">menu 9</a></div>
<div style="position:absolute;margin-left:900px"><a href="#"onclick="test10()">menu 10</a></div>
<div style="position:absolute;margin-left:1000px"><a href="#"onclick="test11()">menu 11</a></div>
<div style="position:absolute;margin-left:1100px"><a href="#"onclick="test12()">menu 12</a></div>
<div onmouseout="test13()" id="div1" style="position:absolute;top:30px;background-color:red;width:200px;height:200px;display:none">
</div>
<div onmouseout="test14()" id="div2" style="position:absolute;top:30px;margin-left:350px;background-color:navy;width:200px;height:200px;display:none">
<div id="div3" style="position:absolute;top:30px;margin-left:350px;background-color:green;width:200px;height:200px;display:none">
<div id="div4" style="position:absolute;top:30px;margin-left:350px;background-color:yellow;width:200px;height:200px;display:none">
<div id="div5" style="position:absolute;top:30px;margin-left:350px;background-color:pink;width:200px;height:200px;display:none">
<div id="div6" style="position:absolute;top:30px;margin-left:350px;background-color:grey;width:200px;height:200px;display:none">
<div id="div7" style="position:absolute;top:30px;margin-left:350px;background-color:brown;width:200px;height:200px;display:none">
<div id="div8" style="position:absolute;top:30px;margin-left:350px;background-color:blue;width:200px;height:200px;display:none">
<div id="div9" style="position:absolute;top:30px;margin-left:350px;background-color:purple;width:200px;height:200px;display:none">
<div id="div10" style="position:absolute;top:30px;margin-left:350px;background-color:orange;width:200px;height:200px;display:none">
<div id="div11" style="position:absolute;top:30px;margin-left:350px;background-color:white;width:200px;height:200px;display:none">
<div id="div12" style="position:absolute;top:30px;margin-left:350px;background-color:navy;width:200px;height:200px;display:none">
</div>
</body>
</html>
j'essaye de faire en sorte que quand on clique sur un lien ( menu 1) ça affiche la div propre au lien (div1) et cacher les autre div (div,2,3,4,5,6...) mais bizarrement cela ne fonctionne que pour le menu 1 et 2
Afficher la suite
Modifié par prosthetiks le 12/01/2012 à 20:17