change slideToggle() behaviour to display:inline-block instead of display:block?

iHaveacomputer picture iHaveacomputer · Nov 16, 2011 · Viewed 52k times · Source

my target slideToggle() div needs to be display:inline-block instead of display:block when it's open. Is there a way to change the jquery behavior here?

Edit:

i'm using jQuery 1.7.0 at the moment. Also, the <div> is initially at display:none and should expand to display:inline-block after a click on a link; but apparently the default state for slideToggle() in this situation is display:block ...

Answer

black picture black · Apr 4, 2012

A little birdie told me...

$('#my-block').slideToggle('medium', function() {
    if ($(this).is(':visible'))
        $(this).css('display','inline-block');
});