I dont know why this code is not working! why is it showing the alert blank?
<html lang="en">
<head>
<title>Document</title>
<style>
#dd{
height: 300px;
width: 300px;
background-color: mediumblue;
color: white;
}
</style>
</head>
<body>
<label>Color </label><input id="in1" type="text">
<hr>
<div id="dd">
</div>
<script>
var colorTextBox = document.getElementById("in1");
var div = document.getElementById("dd");
div.onclick = function(){
colorTextBox.value = div.style.backgroundColor;
alert(div.style.backgroundColor);
}
</script>
</body>
</html>
when the div is clicked the background color of the div should be written inside the input box and also shown in the alert.