Search code examples
jqueryslidetoggle

Slidetoggle bug on jquery 1.12.4


i recently update my website, with a new jquery version. But this creat a bug in a small Jquery script i have write. My syntax should be bad for the last version. Thanks for helping me, this is the code:

//-----------------------XX-- + & - BOX--XX---------------
$('.texte , #devis_hide').css( 'display','none');
$('.plus , #plus_bis').css('cursor','pointer').toggle(
    function() {$(this).next().slideToggle(400); this.src = this.src.replace("plus","moins");},
    function() {$(this).next().slideToggle(400);this.src = this.src.replace("moins","plus"); }
);

The concept is really simple, an + or - that deploy the just next to him.

Sincerely.


Solution

  • Toggle is now deprecated and do not have the same effect, so i replace my code by this one:

    $('.texte , #devis_hide').css( 'display','none')
    
    $('.plus, #plus_bis').click(function(){
      if ( $(this).next().is(':visible') ) {
         $(this).attr('src', $(this).attr('src').replace("moins","plus"))
      } else {
         $(this).attr('src', $(this).attr('src').replace("plus","moins"))
      }
      $(this).next().slideToggle(400);
    })