jQuery jqueryjavascripthtml 13/02/2016

Get reference to new element added with jQuery.append()

First, create new element and save reference to object:

var board = $('<div class="chess-board"></div>');

Then, add new object to DOM via `appendTo()`` routine:

var board.appendTo('#container');

or, if you already have reference to container, use that instead of selector:

var container = $('#container');
var board.appendTo(container);