Generate divs with jQuery

Generate divs with jQuery

hey guys i need your help

i want to make a div generator. so when i write a number in the input field and press the button, the divs should generate.

so thats my html

<div id="tileContainer">
    
   
</div>
<input type="textbox" value="3" id="generatetile">
<input type="button" id="tiles" value="generate">



thats my js

$(document).ready(function(){
    var x = $("#generatetile").val();  
    for(var i=0; i< x ; i++){
        $("#tileContainer").append("<div class='tile'></div>");
    }
});


my css

.tile {
    background-color: black;
    width: 100px;
    height: 100px;
    float: left;
    margin: 10px;
}


please help me

sincerly