But what if you only want to change Y co-ordinate of an image without disturbing X Co-ordinate?
Firefox doesn’t support backgroundPositionX or backgroundPositionY. however it does support backgroundPosition by itself. I was working on a prototype library so I used split(” “) with delimiter as space to split the values and store it in an array.
var temp = $('header').getStyle('background-position'); var split = temp.split(" "); $('header_horizontal_position').value = split; $('header_vertical_position').value = split;
Using the value of X co-ordinate from split, I wrote the code below:
document.getElementById(curImage).style.backgroundPosition = split + " -40px";
So the X co-ordinate remained the same and I was able to change the Y co-ordinate.