jQuery css() set css background position update

Description

jQuery css() set css background position update

View in separate window


<!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>
        /*from w w w  .j  a  va 2  s.c om*/
        <script>
        //extending, going the other way
        $(function() {
            var yPos = 0;
            var timer = setInterval(start, 50);
        
            function start() {
                yPos = yPos - 5;
                $("body").css({ backgroundPosition: "50% " + yPos + "px" });
            }
        });
        </script>    
    </head>
    <body></body>
</html>



PreviousNext

Related