07.02.2010

IE and jQuery

A little time saver hint: Internet Explorer 8′s JavaScript engine seems to interpret associative arrays (in this case objects) different than others (tested in Firefox 2, 3 and 3.5, Opera and Safari).
While other browser’s JS engines interpret the following as just fine –

    $('div.panel').css( { color : '#C00', width : '238px' } );

– IE will stop executing the JavaScript. What the issue is? The issue is that Internet Explorer looks for the variables color and width. As we never declared them inside of our JS, he will have a hard time finding anything that might match. To work around this problem, just put the properties in quotes:

    $('div.panel').css( { 'color' : '#C00', 'width' : '238px' } );

Dan Borufka

...you might also be interested in:

1 comment

  1. February 19, 2010

    [...] forget to put the parameters in quotation marks, we’ve talked about that here. Just as jQuery.beforeafter, you can address our script via Javascript and make it show only the [...]

Leave a Reply