I created a simple code that has a div with a background color of blue and a submit button. Now, If I click the submit button, the background color of the div should change to red. But the code is not working according to the desired output.
function click(){
document.getElementById("box").style.backgroundColor="red";
}
#box{
border: 1px solid black;
width: 50px;
height: 50px;
background-color: blue;
}
<!DOCTYPE>
<html>
<title>PRACTICE</title>
<head>
<link rel="stylesheet" href="practicestyle.css"/>
<script src="practicescript.js"></script>
</head>
<body>
<div id="box"></div>
<form>
<input type="submit" value="submit" onclick="click()">
</form>
</body>
</html>