Home > DeveloperSection > Forums > Jquery during slideToggle() class change event
Mark Devid
Mark Devid

Total Post:102

Posted on    May-11-2013 2:22 AM

 JQuery JQuery 

 1 Reply(s)
 1603  View(s)
Rate this:
Hi Expert!

Hi there I would like to use slideToggle for a drop down the matter I struck ed there was am trying to toggle swap a anchor element's class in the parent div while 

Slidedown .foo class and while slideup .eee class should apply and a likely demo for this question is here

 var id=$(this).attr('id');
 if($(this).is(':visible')){  $("#"+id+" a").addClass("foo"); }

Thanks in advance! 


Total Post:604

Posted on    May-11-2013 9:54 AM

Hi Mark!

Try as following. I hope it is helpful for you

$(".select_type").click(function () {
    var id = $(this).attr('id');
    $("#" + id + "_drop").slideToggle(function () {
       $("#" + id + " a").attr({
            'class': function (_, oldVal) {
                return oldVal === "up_arr" ? "down_arr" : "up_arr"; //Change the class here, based on prev value.

Don't want to miss updates? Please click the below button!

Follow MindStick