you're reading...

How to fix an empty element hight in Internet Explorer with jQuery

Internet Explorer 7 doesn’t render an empty element right, when this element has some layout features (for example, background). The element is supposed to be rendered as it were non existent on the page, instead we have an annoying box with non-zero dimensions. It’s frustrating when you have on your page a message box for potential error and success messages, and when there are no messages, you still see it in IE.

The solution is to hide the box when there is no text in it.

$j(".message-box").each(function() {
    if(jQuery.trim($j(this).text()).length == 0) {

If the page is rendered with a message, then the box is shown. If there is a message rendered over AJAX, then we rerender the whole message box and it’s visible originally.


About RailsBlogger

I'm a Software Developer with over 10 years of experience, Java and Ruby on Rails.


No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

ip tracing
%d bloggers like this: