biggre 
tu as ajouté le code dans l'evenement "click" 
le code doit être exécuté a chaque chargement de page, il doit être hors du "click" mais dans le "ready", exemple :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| $(document).ready(function() {
$("#menu_left dt.sousMenu").hide();
$("#menu_left dl.toggleSousMenu span").each(function() {
var TexteSpan = $(this).text();
$(this).replaceWith('<a href="" title="Afficher le sous-menu">' + TexteSpan + '<\/a>');
});
$("#menu_left dl.toggleSousMenu > a").click(function() {
if ($(this).next("dt.sousMenu:visible").length != 0) {
$(this).next("dt.sousMenu").slideUp("normal");
}
return false;
});
$(this).next("dt.sousMenu").slideDown("normal");
if (window.location.href = 'http://localhost/site2/tarte.php' == true) {
$("#menu_left dt.sousMenu").show();
}
if (window.location.href = 'http://localhost/site2/chocolat.php' == true) {
$("#menu_left dt.sousMenu").show();
}
if (window.location.href = 'http://localhost/site2/creme.php' == true) {
$("#menu_left dt.sousMenu").show();
}
}); |
plutot que tester l'url en entier, tu pourrais faire ceci (ca sera moins chiant a chaque changement de serveur !) :
if( window.location.href.indexOf('tarte.php') !== - 1 ){ // code a exxecuter
je ne pense pas que l'utilisation des TAGs DT/ DL dans un menu soit une bonne chose, tu aurais pu te contenter de UL / Li .
Partager