Simple affichage de texte
Bonjour à tous,
J'aimerai savoir si quelqu'un pouvait m'aider quant au code suivant :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
</head>
<script language="Javascript">
function cacher_afficher(id) {
if ($("#"+id).is(":hidden")){
$("#"+id).fadeIn("slow");
} else {
$("#"+id).fadeOut("slow");
}
}
</script>
<body>
<a href='javascript:;' onclick="cacher_afficher(test);">Afficher/Cacher</a>
<p id="test" style="visibility: hidden;">Texte blabla</p>
</body>
</html> |
En fait, j'aimerai que le texte contenu dans la balise <p> s'affiche et se cache au clic sur la lien, tout simplement. Pour cela j'ai créée la fonction "cacher_afficher()", mais ça ne marche pas, et je n'arrive pas à trouver mon erreur malgré les tutos sur internet :oops:
Je sais faire en javascript mais je voulais avoir un petit effet à l'aide de JQuery.
Quelqu'un pourrait il m'aider ?
D'avance merci.