jquery - Changing button symbol after the toggle is complete -


so, have button showing , hiding div id of "details" , button id of "more" while changing symbols on click , down arrow. (it starts details hidden , down chevron visible. image swap (class change) happen after toggle animation complete instead of on click. how this?

('#more').click(function() {   $('#details').toggle('slow');  }); $('#more').click(function()  {    if ($(this).html() == '<i class="icon-chevron-up"></i>')    {       $(this).html('<i class="icon-chevron-down"></i>');    }    else    {       $(this).html('<i class="icon-chevron-up"></i>');    }  }); 

.toggle() has callback. use it!

$('#more').click(function() {   var $el = $(this);    $('#details').toggle('slow', function() {     if ($el.html() == '<i class="icon-chevron-up"></i>') {        $el.html('<i class="icon-chevron-down"></i>');      }      else {        $el.html('<i class="icon-chevron-up"></i>');      }    }); }); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -