Using JS to realize css gradient can not get the desired effect.

I would like to try to use the setInterval () method with the rgb () value to see if the animation effect that changes over time can be achieved.
the code is as follows

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Page Title</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        -sharpbox{
            margin:  0 auto;
            margin-top: 200px;
            width: 200px;
            height: 200px;
            background-color: rgb(0, 0, 0);
        }
    </style>
</head>
<body>
    <div id="box"></div>
    <script >
        var div = document.getElementById("box");
        var color = document.defaultView.getComputedStyle(box,null);
        document.write(color.backgroundColor);
        // div.style.backgroundColor = "blue";
        var i = 0;
        var newColor = "rgb(i,i,i)";
        // div.style.backgroundColor = "rgb(0,i,0)";
        function addg(){
            i += 10;
            div.style.backgroundColor = "rgb(i,i,i)";//
            // document.write(color.backgroundColor);
            console.log(i);
            console.log(color.backgroundColor);//000
        }
        setInterval("addg()",100);
    </script>
</body>
</html>

print in the console and find that I can increase normally, but the RGB value is always 0. This is why.
Whoa, please do not hesitate to comment

.
Jul.15,2022

        var i = 0;
        var newColor = "rgb(0,0,0)";
        function addg(){
            i += 10;
            (i>255)&&(i=0);//i
            div.style.backgroundColor = `rgb(${i},${i},${i})`;//
            // document.write(color.backgroundColor);
            console.log(i);
            console.log(color.backgroundColor);//000
        }
        setInterval('addg()',100);

div.style.backgroundColor = "rgb";
style is assigned to "rgb" string, invalid CSS will not be executed.
change to div.style.backgroundColor = rgb (${I}, ${I}, ${I}) ;.
in addition, the I value can be added to determine whether it is less than 255

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bdbcb3-137e9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bdbcb3-137e9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?