really hoping someone can help me out because this is driving me mad! I'm relatively new to Javascript and Bootstrap so I'm sure it's something obvious
I'm trying to create a set of checkboxes from an array of data to an attendance form. I'm using bootstrap and specifically the checkbox and buttons to generate a dynamic set of buttons.
Whatever I try, the buttons don't draw correctly. Test code below which shows a button correctly drawing, then when I try and click another button to draw more buttons, what gets displayed is incorrectly formatted. They are small with no text and have no label - hope this makes sense. Everything looks the same between the working button and the jquery that creates the buttons so I'm at a complete loss!
function loadButtons() {
for (var i = 1; i <= 6; i++) {
var $chk = $('<div class="btn-group-toggle" data-toggle="buttons"><label class="btn btn-secondary active"><input type="checkbox" checked> Checked');
$("#append").append($chk);
}
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<h1>Hello, world!</h1>
<div id="append" name="append">Append here</div>
<button onclick="loadButtons()" b>button</button>
<div class="btn-group-toggle" data-toggle="buttons">
<label class="btn btn-secondary active">
<input type="checkbox" checked> Checked
</label>
</div>
</label></div>to the end of that string.