My problem is that I am using the .hover method to get the x position of a background-img. When i ask typeof it returns as undefined. When i ask it to alert me the returned value it gives me: “10px”, how can I make this an integer value that gets stored in the variable properly?
My function goes as follows:
$("#menu li").hover(
function () {
var xPos = $(this).css('background-position-x')
$(this).stop().animate({
backgroundPosition: xPos + "px 0px"
}, 500);
},
function () {
var xPos = $(this).css('background-position-x')
$(this).stop().animate({
backgroundPosition: xPos + "px 35px"
}, 500);
}
);
You can just remove the ‘px’