Reputation: 1005
I have a page where a div takes a while to load in.
The simple code in CSS stops it from ever loading:
.object-container{
display:none;
}
However, I do need it to display by default, and to only NOT display based on a condition.
So I have:
if (x == 1)
{
alert('here!');
//$('.object-container').css("display", "none !important");
$('.object-container').attr('style','display: none !important');
}
...and the alert pops up, but every time the DIV displays anyway after the page loads for a while. What might be happening?
Upvotes: 0
Views: 49
Reputation: 2422
$('.object-container').attr('style','display: none !important');
will overwrite all the inline-styles applied on that particular element.
This may be causing the issue for you. You should change the display
property alone by
$('.object-container').hide()
or
$('.object-container').css('display','none')
Upvotes: 1