Dmitriy Apollonin
Dmitriy Apollonin

Reputation: 1478

Show hidden inline-block elements with jquery 1.9

I've problem with showing hidden blocks, if they are css: inline-block.

div.profile{
    display: inline-block;
}


<div class='profile' style='display: none;'>profile info</div>

But when i do $('.profile').show() it becomes style='display: block' (i can see it in firebug) and overrites my css style...

How can i fix this?

btw, in jquery 1.4 it works correctly.

Thanks.

UPD

$.css('display', 'inline-block'), imo, is not universal solution.

Upvotes: 1

Views: 841

Answers (3)

techfoobar
techfoobar

Reputation: 66673

While setting it explicitly to inline-block works in this case, you should ideally be setting it to '' to apply whatever comes from the CSS, be it inline, or inline-block or block

$('.profile').css('display', ''); // switch it back to whats specified in the CSS

Upvotes: 0

Ejaz
Ejaz

Reputation: 8872

$('.profile').css('display', 'inline-block')

Upvotes: 0

Alvaro
Alvaro

Reputation: 41605

You should change the css style instead of using the show function, which changes it to block.

$('.profile').css('display', 'inline-block');

Upvotes: 3

Related Questions