I have the following code in may page
var x = parseInt($(this).css('backgroundPosition').split(" ")[0]);
Everything works fine in IE9 and FF and Chrome, even Iphone but IE8 and IE7 throws an error, I debugged the issue to be that the .css method can’t resolve the property.
It seems like the document.ready function I use at the bottom of the page loads this code before the css is applied to the element, in this context the this is a td table element
Any ideas on how to elegantly fix this issue
Thank you
I do get
undefinedon thebackgroundPosition(andbackground-position) property using jQuery.It does look like you can access the X and Y in
background-positionin IE if you refer to each individually:In IE7/8 (using IE9 console):
http://jfcoder.com/test/bgpos.html
However, it does look like it doesn’t work in Firefox (doesn’t output anything). So I adjusted the code to detect IE.