Skip to main content

Bug Tracker

Side navigation

#1688 closed bug (fixed)

Opened September 19, 2007 09:25PM UTC

Closed November 19, 2007 05:13PM UTC

Applying margin in .css() causes error in IE7

Reported by: digitalspaghetti Owned by:
Priority: critical Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: Cc:
Blocked by: Blocking:

From a widget I am creating, I apply CSS using the .css function. In the below snippet, i've commented out the property margin: '0 auto', as it causes an error in jquery.js

$('<li></li>').attr('id', 'question-' +
height: '1em',
overflow: 'hidden',
padding: '0',
/*margin: '0 auto',*/
width: '98%',
borderTop: '1px solid #000'

The error is in line 732 in jQuery.js, within the curCSS function. It seems to be part of a Dean Edwards hack:

From the awesome hack by Dean Edwards

If we're not dealing with a regular pixel number

but a number that has a weird ending, we need to convert it to pixels

Attachments (0)
Change History (3)

Changed September 25, 2007 06:33PM UTC by slthytove comment:1

Note: the same error seems to occur when using the .css() method to RETRIEVE a value for margin as well. A workaround in the case of retrieving is only to retrieve the margin-top, margin-right, margin-bottom, and margin-left values instead of the whole margin value.

Changed October 04, 2007 09:29PM UTC by davidserduke comment:2

I'm having trouble reproducing this bug. Here is my code. Did I do something wrong?

    <style type="text/css">
      #container { background:yellow; }
    <script type="text/javascript" src="../../jquery.js"></script>
    <script type="text/javascript">
      function doIt() {
        $("<li></li>").attr('id', 'question-' + 5)
                height: '1em',
                overflow: 'hidden',
                padding: '0',
                margin: '0 auto',
                width: '98%',
                borderTop: '1px solid #000'

      $(function () {
    <button id="doit">Do It</button>
    <div id="container">
    <div id="adiv"></div>

I tried it in both IE7 and FF2 without a problem.

Changed November 19, 2007 05:13PM UTC by brandon comment:3

resolution: → fixed
status: newclosed

This is working with the latest SVN.