I have an array like this:
var arr = [
{ Group: 'Fruits', Name: 'Apple' },
{ Group: 'Fruits', Name: 'Pears' },
{ Group: 'Veggies', Name: 'Tomatoes' },
{ Group: 'Veggies', Name: 'Carrots' }
];
I want to create checkboxes for each group in my HTML container
so I get an output like this:
<div id="container">
<h4>
Fruits</h4>
<ul id="Fruits">
<li>
<input type="checkbox" name="Apples" id="Fruits-Apples" /><label>Apples</label></li>
<li>
<input type="checkbox" name="Pears" id="Fruits-Pears" /><label></label>Pears</li>
</ul>
<h4>
Veggies</h4>
<ul id="Veggies">
<li>
<input type="checkbox" name="Tomatoes" id="Veggies-Tomatoes" /><label>Tomatoes</label></li>
<li>
<input type="checkbox" name="Carrots" id="Veggies-Carrots" /><label>Carrots</label></li>
</ul>
</div>
What is the best way to do this using jquery?