jQuery: IE Trouble with background-position

My code works perfectly in Firefox, Chrome and other standard-compliant browsers but in Internet Explorer it returns "undefined" and produces errors.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 

<style type="text/css">
#mylink {
display: block;
width: 200px;
text-align: center;
color: #000;
text-decoration: none;
font-weight: 600;
font-size: 30px;
height: 200px;
margin: 20px auto;
line-height: 200px;
border: 1px solid #555;
background: white url(http://www.fareastgizmos.com/entry_images/1206/26/Wikipedia.jpg) no-repeat scroll 50% 50%;

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script> 
<script type="text/javascript"> 

$(document).ready(function() {
 alert( $('#mylink').css("background-position") );



<h1>Hello World</h1>

<a href="#" id="mylink">Hello!</a>


Open in new window

LVL 16
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSenior Systems and Integration DeveloperCommented:
The problem is that IE doesn't recognise the "background-position" pseudo-class. It will noly recognise the more explicit "background-poistion-x" and "background-position-y" attributes.

It's debatable whether or not this should be catered for in the jQuery library or not. But, until the world resolves that issue, you can use the workaround described here:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.