I have a list of elements where I want to create list like structure with the Bootstrap element (example):
<div class="list-group">
<a href="#" class="list-group-item active">
<h4 class="list-group-item-heading">List group item heading</h4>
<p class="list-group-item-text">...</p>
</a>
</div>
I figured that I will do something like:
foreach(element)
{
$("#ul").append($("<a href='" + element +"'>").text(element));
}
<div class="container">
<div id="ul" class="list-group">
</div>
This works fine but I am not sure how to do the other nested elements (<h4>
and <p>
) and also set their text
property. Also is there a cleaner way to do the href
part of <a>
element ? Any hints and tips are appreciated.