<div id="nav">
Some Text
</div>
<input type="text" id="color"><button onClick="changeColor()">Change</button>
<script>
function changeColor(){
var colorCode = document.getElementById('color').value;
var nav = document.getElementById('nav');
nav.style.background = "'"+colorCode+"'";
}
</script>
When i enter for ex.: red in the input field and than press the button, nothing happens.