I run in to a situation where I need to append a class called "active" in to a set of dynamically created divs. My issue is that I am suppose to only add the class "active" to the very first of the dynamically created div set and rest not have it.
Here is my html example.
<!-- Begin Carousel -->
<div id="carousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel" data-slide-to="0" class="active"></li>
<li data-target="#carousel" data-slide-to="1" class=""></li>
<li data-target="#carousel" data-slide-to="2" class=""></li>
</ol>
<!-- Wrapper for slides -->
<div id="CAROUSEL_CONTENTHERE" class="carousel-inner">
<!-- DYNAMICALLY CREATED DIVS GO HERE -->
</div>
</div>
Here is what the dynamically created DIVs look like
<div class="item bgwhite"> <!-- class active should append here. -->
<div class="carousel-img-full">
<a href="#"><img src="img/banner2.jpg" alt=""></a>
</div>
</div>
So essentially I would like
<div class="item bgwhite active">
<div class="carousel-img-full">
<a href="#"><img src="img/banner1.jpg" alt=""></a>
</div>
</div>
<div class="item bgwhite">
<div class="carousel-img-full">
<a href="#"><img src="img/banner2.jpg" alt=""></a>
</div>
</div>
<div class="item bgwhite">
<div class="carousel-img-full">
<a href="#"><img src="img/banner3.jpg" alt=""></a>
</div>
</div>
Any idea how I can approach this using jquery? Thank you for taking your time to read this.