Skip to main content

Bug Tracker

Side navigation

#10796 closed bug (fixed)

Opened November 15, 2011 05:17PM UTC

Closed December 06, 2011 10:21PM UTC

Last modified April 07, 2013 01:03PM UTC

Bug in IE7 with $('#el').css.('background-position')

Reported by: Owned by: mikesherov
Priority: low Milestone: 1.7.2
Component: css Version: 1.7
Keywords: Cc:
Blocked by: Blocking:


I found that $('#el').css.('background-position') is defined as "undefined" in IE7 (maybe in IE8 too, I had no tested yet) with jQuery 1.5+. In jQuery 1.42 it works well!

Here is an exampe code:

<meta charset="utf-8">
<script src=""></script>

  <div id="test" style="background-position:0 0;">text</div>
      alert( $('#test').css('background-position') )


Try to change jquery to 1.42 and it gonna works.

Attachments (0)
Change History (20)

Changed November 15, 2011 05:20PM UTC by comment:1

Changed November 15, 2011 06:44PM UTC by timmywil comment:2

component: unfiledcss
milestone: None1.7.1
owner: → timmywil
priority: undecidedlow
status: newassigned

Computed style is undefined and our fallback to uncomputed is not in the codepath because ret is not null.

Changed November 15, 2011 07:02PM UTC by anonymous comment:3

I apologize, but I do not speak English as well. I don't understand your message even whith google translater, because there a lot of hard to translate words. I apologize once again. Can you tall me please how can I get the background-position value with new version of jQuery.


Changed November 15, 2011 07:15PM UTC by timmywil comment:4

Sorry, that was more a message for the bugs team and myself. We plan on fixing this issue for the next release, but it is not a regression because I can't imagine it has worked in any version of jQuery. For now, you can get the background-position of this particular element like this:

Changed November 15, 2011 07:27PM UTC by anonymous comment:5

Thanks! The second example works

Changed November 18, 2011 02:41PM UTC by anonymous comment:6

Replying to [comment:4 timmywil]:

Thank you for your tip but with IE6 it only works with inline css, with external css it returns an empty string (instead undefined) :(

Changed November 18, 2011 03:09PM UTC by timmywil comment:7


Bumping to 1.7.2.

Changed November 18, 2011 03:27PM UTC by comment:8

Replying to [comment:4 timmywil]:

The trick for this works well with f*****g IE is to use 'background-position-x' and 'background-position-y', please implement it in jquery to prevent writing each time this

Thank you very much !

Changed November 18, 2011 05:05PM UTC by timmywil comment:9

@superk: that's not really related to this ticket. The stackoverflow issue does not have to do with jQuery core.

Changed November 19, 2011 03:04AM UTC by mikesherov comment:10

Replying to [comment:2 timmywil]: Computed style is undefined and our fallback to uncomputed is not in the codepath because ret is not null.

not the only problem. Getting back a value like "0px 0px" incorrectly triggers the "awesome hack by Dean Edwards".

Changed November 19, 2011 04:36AM UTC by mikesherov comment:11

Changed November 19, 2011 02:34PM UTC by superk303 comment:12

Replying to [comment:9 timmywil]:

You probably didn't red my post correctly, I just wrote that it would be nice that $('.elem').css('background-position') returns a correct string such '10px 10px' instead of undefined or an empty string, with external css on IE6 (and maybe other laters) as you can see on this jsfiddle with IE6 (so IT IS a jquery issue) :

And it can be easily implemented thankfully to the tricks explained at the mentionned stackoverflow question with the properties 'background-position-x' and 'background-position-y' concatened...

thanks dudes

Changed November 19, 2011 05:58PM UTC by timmywil comment:13

@super: I don't think you understand. There is no computed background position in your example in IE because there is no background. Retrieving bpx and bpy is unnecessary.

Changed November 20, 2011 10:37AM UTC by superk303 comment:14

Replying to [comment:13 timmywil]:

well ok, I corrected the test :

It can be needed to simulate a hover event with the sprite method and so just changing background-position...

Changed November 28, 2011 02:40AM UTC by mikesherov comment:15

owner: timmywilmikesherov

Changed November 30, 2011 03:39PM UTC by sindresorhus comment:16

#10923 is a duplicate of this ticket.

Changed November 30, 2011 05:48PM UTC by comment:17

The problem is that when you request any CSS property that is not set or does not exist in an elements' style, it should return null. Requesting say:


Returns null, but the following:


Causes an internal jQuery error in 1.7.1, and doesn't in 1.6.4

Changed December 06, 2011 10:21PM UTC by Mike Sherov comment:18

resolution: → fixed
status: assignedclosed

Fix #10796. Allow IE<9 to retrieve uncomputed styles.

Changeset: 6aa4095ed62e3e37dae4c39c00fb627a3b282307

Changed May 30, 2012 12:16PM UTC by sindresorhus comment:19

#11838 is a duplicate of this ticket.

Changed April 07, 2013 01:03PM UTC by gpakosz comment:20

looks like it doesn't work anymore on 1.9.1