<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body{
background-color: red;
transition: 2s;
}
</style>
</head>
<body>
<input type="text" id="fon"> Цвет фона <button id="but">сменить</button>
<script>
document.getElementById('but').onclick = e => document.body.style.backgroundColor = document.getElementById('fon').value;
</script>
</body>
</html>