Transition en js d'un menu par onclick
Bonsoir,
éclairez moi s'il vous plait, je n'arrive pas du tout à faire fonctionner mon script,
je souhaite que après avoir cliqué sur + et bien la div s'ouvre lentement vers le bas en se "déroulant".
Mon script.js :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| function apparaitre(texte, afficher_cacher){
var valeur_display = document.getElementById(texte).style.display;
if (valeur_display == "none")
{
document.getElementById(texte).style.display = "block";
document.getElementById(afficher_cacher).innerHTML = "<a href='#' onclick='apparaitre(" + text + "," + afficher_cacher + ");'>Annuler</a>";
}
else
{
document.getElementById(texte).style.display = "none";
document.getElementById(afficher_cacher).innerHTML = "<a href='#' onclick='apparaitre(" + text + "," + afficher_cacher + ");'>Modifier mot de passe</a>";
}
}<br>
$(document).ready(function()
{
$(texte).hide();
$(afficher_cacher).click(function()
{
$(this).next(texte).slideToggle(300);
});
}); |
Et le code :
Code:
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
| <script type="text/javascript" src="script.js"></script><br> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <br> <div id="gauche">
<div style="border:2px solid #000;border-radius:10px 10px 0px 0px;">
Items<br>description
<div style="float:right;border-radius:10px;" id="aff1"><a href="#" onclick="apparaitre('txt1', 'aff1');">+</a></div>
</div>
<div style="border:1px solid #000;border-radius:0px 0px 10px 10px;">
<div id="txt1" style="display: none; text-align: left;">texte chaché1<br> hahatexte
chaché1<br>texte chaché1<br>texte chaché1<br>texte chaché1<br>texte chaché1<br>texte
chaché1<br></div>
</div>
</div>
<div id="centre">
<div style="border:2px solid #000;border-radius:10px 10px 0px 0px;">
Rangs<br>description
<div style="float:right;border-radius:10px;" id="aff2"><a href="#" onclick="apparaitre('txt2', 'aff2');">+</a></div>
</div>
<div style="border:1px solid #000;border-radius:0px 0px 10px 10px;">
<div id="txt2" style="display: none; text-align: left;">texte chaché2<br> hahatexte
chaché2<br>texte chaché2<br>texte chaché2<br>texte chaché2<br>texte chaché2<br>texte
chaché2<br></div>
</div>
</div> |
Plus d'infos regardez le résultat : ma page
Merci :)