I am just new in programming and that's my first attempt to learn something new. I can't get what is wrong with my code, because it doesn't want to work. All I need is to change the bg-color just by clicking on the div. It works if you remove 1st line of code until "function", but only on onload the page.
document.getElementById("trying").onclick = function(){
    var someText = document.getElementById("textArea").value;
    document.getElementById("randomText").innerHTML = someText;
   }
    document.getElementById("mainBox").onclick =
    function getRandomColor() {
                
                var letters = '0123456789ABCDEF'.split('');
    
                var color = '#';
    
                for (var i = 0; i < 6; i++ ) {
        
                    color += letters[Math.floor(Math.random() * 16)];
    
                }
    
                return color;
            }
    document.getElementById("mainBox").style.backgroundColor = getRandomColor();.mainBox {
    width: 400px;
    height:350px;
    background-color:pink;
    margin-right:auto;
    margin-left:auto;
   }
   #textArea {
    margin-left:100px;
   }<div id="mainBox" class="mainBox">
    <p id="randomText" align="center">U know who you are?</p>
     <input type="text" id="textArea">
     <button id="trying">Try it!</button>
    </div> 
     
    