jQuery: “Could not get the display property. Invalid argument.” error in Internet Explorer 7

I’m really very new (using it for a week or two) to jQuery myself and this had me stumped for a few minutes. I got the error “Could not get the display property. Invalid argument.” in Internet Exploder 7 and not in Firefox 3.6 so typical :). I went through the usual troubleshooting method of commenting line by line I found the offending line.

It looked something like this

$("#helpdiv").animate({ position: "fixed", top: ($(window).height() - $("#helpdiv").height()) - 2 }, 2000);

So I commented out all the options between {} and added them back one by one and found that it was the position: “fixed” option that was causing the error.

Solution:

Remove the position: “fixed” option from the animate and set it with css then do the animate.

$("#helpdiv").css({ position: "fixed" });
$("#helpdiv").animate({ top: ($(window).height() - $("#helpdiv").height()) - 2 }, 2000);
Advertisements