0

See my code below

$(document).ready(function() {

    creatersdropdown();

    var $dropTrigger = $(".rsdropdown dt a");
    var $languageList = $(".rsdropdown dd ul");

    // open and close list when button is clicked
    $dropTrigger.toggle(function() {
        $languageList.slideDown(200);
        $dropTrigger.addClass("active");
    }, function() {
        $languageList.slideUp(200);
        $(this).removeAttr("class");
    });

});

.toggle() is not working with jQuery-1.9.1 or later, so what is the instead of .toggle() method?

how to write the code above without using .toggle() in jQuery-1.9.1 or later?

Rousnay
  • 78
  • 7
  • 2
    Possible duplication is here: http://stackoverflow.com/questions/12579667/what-to-use-instead-toggle – Pavlo Feb 14 '14 at 19:55

1 Answers1

1

you can use .is('visible') jquery method. and do as you wish in your case it would be something like :

$("#someButton").click(function () {
    if ($dropTrigger.is('visible')) {
            $languageList.slideUp(200);
            $(this).removeAttr("class");
        }else {
            $languageList.slideDown(200);
            $dropTrigger.addClass("active");

        }
    });
Ori Refael
  • 2,888
  • 3
  • 37
  • 68