The problem is that the method append()
returns the selected item. In your case, this is an element .dynamic
. After adding, you install html()
from .dynamic
, which then overwrites div
, added to append()
.
To accomplish what you need, you can create an element div
separately before adding:
$('<div />', {
class: 'clipboardContent',
html: window[recentPerson].fullname + '<br><span style="color: lightgray; font-size: 10pt">' + window[recentPerson].mail + '</span>'
}).appendTo('.dynamic');
Working example
Or you can save your current method and include HTML in the line you add:
$('.dynamic').append('<div class="clipboardContent">' + window[recentPerson].fullname + '<br><span style="color:lightgray; font-size:10pt">' + window[recentPerson].mail + '</span></div>');
, CSS style
. , , , JS , .