Although I have a strong background in PHP coding, using javascript is a new venture for me so I hope this question doesn't sound naive.
My objective is to create a button that, when clicked, shifts the background-position of a specified DIV object by one pixel.
Despite scouring Google and various websites for guidance, I have been struggling to find a suitable javascript function that achieves my desired outcome.
The current version of my script looks like this:
<SCRIPT TYPE="text/javascript">
var xObject = 0; // Global
function xMinus(ele) {
xObject-=1;
document.getElementById(ele).css({ 'backgroundPosition': xObject + 'px ' + 0 + 'px' });
}
</SCRIPT>
My intention is for the background to shift left by one pixel upon clicking the button with onclick="javascript:xMinus('divID');". However, when clicked, the Error Console displays "Error: document.getElementById(ele).css is not a function".
Despite attempting alternative approaches, I continue to encounter similar outcomes or "Variable is not defined" errors. It's clear that I am feeling lost in this process. Any assistance would be greatly appreciated as I'm working on this project for friends and don't want to keep them waiting too long.