Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery slideToggle display type

I'm using a jQuery slideToggle to show a hidden table row but it sets the display style to block and I need to to display table-row. any ideas how i could accomplish this?

thanks in advance

like image 822
ErnieStings Avatar asked Aug 12 '09 13:08

ErnieStings


People also ask

What does slideToggle do in jQuery?

jQuery slideToggle() Method The slideToggle() method toggles between slideUp() and slideDown() for the selected elements. This method checks the selected elements for visibility. slideDown() is run if an element is hidden. slideUp() is run if an element is visible - This creates a toggle effect.

What does slideToggle do?

The . slideToggle() method animates the height of the matched elements. This causes lower parts of the page to slide up or down, appearing to reveal or conceal the items. If the element is initially displayed, it will be hidden; if hidden, it will be shown.


1 Answers

I figured out a solution to this problem - check if the display has been set to block (if the element has been toggled to be shown) and if so set to desired display type.

$('a.btn').on('click', function() {
    $('div.myDiv').slideToggle(200, function() {
        if ($(this).css('display') == 'block') $(this).css('display', 'table-row'); // enter desired display type
    });
});
like image 63
inorganik Avatar answered Oct 12 '22 10:10

inorganik