Bug Tracker

Opened 15 years ago

Closed 15 years ago

#1688 closed bug (fixed)

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-' + item.id)
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

Change History (3)

comment:1 Changed 15 years ago by slthytove

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.

comment:2 Changed 15 years ago by davidserduke

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <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.

comment:3 Changed 15 years ago by brandon

Resolution: fixed
Status: newclosed

This is working with the latest SVN. http://brandonaaron.net/jquery/tickets/1688/test.html

Note: See TracTickets for help on using tickets.