Alex Rivera | Logout

How to find the background-position / background-image etc for multiple backgrounds using jQuery in Safari

Asked 2011-07-19T07:24:53.837
35

Maybe I'm missing something here.

I'm trying to get the current background info for an element (div) with multiple backgrounds, set using the longhand background-repeat, background-position and background-image.

Using jQuery, I simply do var bPos = $('#element').css('background-position') to get the set of current positions, which will give me something like '0 0, 100px 100px, left bottom' in Firefox and Chromium (currently versions 5 and 12 respectively), but in Safari (version 5 on OS-X) it just returns the first value pair ('0 0'). These CSS values are set in an external stylesheet.

Does anyone have any idea as to why this is, and how to go about it to get the full set of value pairs in Safari (using the shorthand background property doesn't do it either)?

Edit:

Here is the CSS that is used in an external style sheet:

#page{
    background-repeat: repeat-x, repeat-x, repeat-x, repeat-x, repeat-x;
    background-image: url('../images/line.png'), url('../images/line.png'), url('../images/line.png'), url('../images/line.png'), url('../images/line.png');
    background-position: 0 798px, 0 653px, 0 125px, 0 88px, 0 78px;
}

Edit:

Ok, I made a test case for this on jsFiddle and have reported it as a jQuery bug since it seems to be reproducible behaviour (although I accept that it might be a browser implementation problem rather than actually a jQuery bug).

Still, if anyone has any ideas...

Edit:

The jQuery ticket has been closed - I take this to mean that it is a Safari bug - I'm not quite sure how to go further from here, but I've posted a bug report with Apple.

Edit:

Edit
Report

1 Answer

-1

You can try to use different classes. That would be easiler.

answered 2011-08-04T13:37:08.830

Your Answer