2016-12-25 1 views

Répondre

1

changement que vous Js fonctionnez comme ci-dessous, il fonctionnera

$(function() { 
    $(".expand").on("click", function() { 
    $(".expand").find(">:first-child").text("+"); 
    $(".detail").css("display","none"); 
    $(this).next().slideToggle(200); 
    $expand = $(this).find(">:first-child"); 

    if($expand.text() == "+") { 
     $expand.text("-"); 
    } else { 
     $expand.text("+"); 
    } 
    }); 
}); 

Trouver cette fiddle.

0

Remplacez votre javascript avec ceci:

$(function() { 
    $(".expand").on("click", function() { 
    if($(this).next().css("display")=="none"){ 
     $(".expand").next().css("display","none"); 
     $expandold = $(".expand").find(">:first-child"); 
     $expandold.text("+"); 
     $(this).next().slideToggle(200); 
     $expand = $(this).find(">:first-child"); 
     $expand.text("-"); 
    } 
    else{ 
     $(".expand").next().css("display","none"); 
     $expand = $(this).find(">:first-child"); 
     $expand.text("+"); 
    } 

    }); 
}); 

est ici un travail codepen

+0

@Honeybeemy Essayez ceci – ab29007

0

Ce serait une solution en utilisant la méthode slideUp.

$(function() { 
    $(".expand").on("click", function() { 
    $('.detail').not($(this).next()).slideUp().prev().find(">:first-child").each(function(){ 
     $(this).text("+"); 
    }); 

    $(this).next().slideToggle(200); 
    $expand = $(this).find(">:first-child"); 

    if($expand.text() == "+") { 
     $expand.text("-"); 
    } else { 
     $expand.text("+"); 
    } 
    }); 
});