Hey there! I'm currently working on a project where I want to gradually change the background when a button is clicked on my website. Below you'll find snippets of JavaScript and HTML code that I'm using for this purpose. Can you take a look and let me know if you spot any mistakes?
var content = document.getElementById('content').style;
var content1 = document.getElementById('content1').style;
var start1;
var start2;
var inti = null;
function changeContent() {
start1 = 1;
start2 = 1001;
inti = setInterval('swapContent()', 20);
}
function swapContent() {
start1 -= 5;
start2 -= 5;
content.top = start1 + 'px';
content1.top = start2 + 'px';
}
<body>
<div id="navigation">
<input type="button" onclick="changeContent()" />
</div>
<div id="content"></div>
<div id="content1"></div>
</body>