jQuery css()
set css background position diagonal
<!DOCTYPE html> <html lang="en"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <style> body {background:url(image7.png) top center fixed;} </style> // w w w . j a v a2 s .c om <script> $(function() { var xPos = 0; var yPos = 0; var timer = setInterval(start, 50); function start() { xPos = xPos - 5; yPos = yPos - 5; $("body").css({ backgroundPosition: xPos + "px " + yPos + "px" }); console.log(yPos); } }); </script> </head> <body></body> </html>