Dynamically Add Elements with JQuery

by zzzrefiddle

HTML

<button id="myBtn">Add Element</button>

<section id="wrapper"></section>

CSS

div {
    font-size: 34px;
    line-height: 100px;
    text-align: center;
    color: white;
    width: 100px;
    height: 100px;
    background: black;
    float: left;
    margin: 10px;
}

JavaScript

var count = 1;

$('#myBtn').click(function(){
		
    $('#wrapper').html('').append(`<div>${count}</div>`);
    
    /* $('#wrapper').append('<div>'+count+'</div>'); */
    
    /* $('<div>').html(count).appendTo('#wrapper'); */
    
    count = count + 1;

});