I'm facing an issue where the data I append to a container div using the .append() function in jQuery ends up trimming the spaces between the labels. Please refer to the attached screenshot for clarification:
Any suggestions on how to resolve this problem would be greatly appreciated.
The JavaScript and HTML code snippets are provided below:
$("a.add-member").click(function(){
var user = '<div class="row user">'+
'<div class="col-md-6"><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1475767754677d60713a777b79">[email protected]</a></div>'+
'<div class="col-md-4">'+
'<div class="user-roles">'+
'<span class="label label-user-role">Role 1</span>'+
'<span class="label label-user-role">Role 2</span>'+
'<span class="label label-user-role active">Role 3</span>'+
'</div>'+
'</div>'+
'<div class="col-md-2 text-center">'+
'<a href="#" class="remove-member"><i class="fa fa-times-circle-o"></i></a>'+
'</div>'+
'</div>';
$("#add-team .users").append(user).hide(0).fadeIn(700);
});
<div class="users">
<div class="row user">
<div class="col-md-6"><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="275f5e5d67544e53420944484a">[email protected]</a></div>
<div class="col-md-4">
<div class="user-roles">
<span class="label label-user-role">Role 1</span>
<span class="label label-user-role">Role 2</span>
<span class="label label-user-role active">Role 3</span>
</div>
</div>
<div class="col-md-2 text-center">
<a href="#" class="remove-member"><i class="fa fa-times-circle-o"></i></a>
</div>
</div>
<div class="row user">
<div class="col-md-6"><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="afdfdeddefdcc6dbca81ccc0c2">[email protected]</a></div>
<div class="col-md-4">
<div class="user-roles">
<span class="label label-user-role">Role 1</span>
<span class="label label-user-role">Role 2</span>
<span class="label label-user-role active">Role 3</span>
</div>
</div>
<div class="col-md-2 text-center">
<a href="#" class="remove-member"><i class="fa fa-times-circle-o"></i></a>
</div>
</div>
</div>