I am trying to create an HTML string and then modify that HTML string with extra HTML and attributes but it's not working. What am I doing wrong?
$(document).ready(function(){
$('body').on('click', 'button', function(){
var thing = '<div class="thing"></div>';
var close = '<a href="#" class="close">close</a>';
$(thing).append(close);
$('.canvas').append(thing);
return false;
});
});
I did get it to work by combining the strings into one variable before appending them to the DOM but this makes what I'm doing harder to read. Is there any other way of doing this?