I'm trying to read values ("img1.jpg", etc.) from a text file on my server and append to a div to create a slide show.
The only catch is I need the first "slide" to have a class of .active applied.
Here's how my text file reads:
Here's the div I want to append to looks like:
<div class="carousel-inner">
<!-- slide -->
<div class="active item slide3 animated fadeInUpBig">
<img src="img1.jpg" />
</div>
<!-- slide -->
<div class="item slide3 animated fadeInUpBig">
<img src="img2.jpg" />
</div>
</div>
Here's what I tried:
$(function () {
var file = "gallery.txt"; // gallery.txt PATH
$('<div />'.load(file, function(data){ // dummy DIV to hold data
var line = data.split('\n');
var NofImages = line.length -1;
for( i=0; i < NofImages; i++ ){
image = './cms/data/img/gallery/homepage/'+ line[i].split('|')[2];
$(".carousel-inner").append("<div class='active item slide3 animated fadeInUpBig'><img src='+ image +' /></div>");
}
}
});