wondering if it is posible to load HTML content this way:
I have this piece of code in JS
var main = [{
title:'Title',
imageProject: 'images/t1.jpg',
content: 'page1.html'
},{
title:'Title2',
imageProject: 'images/t2.jpg',
content: 'page2.html'
},{
title:'Title3',
imageProject: 'images/t3.jpg',
content: 'page3.html'
}]
container = $('<div />', {class:'container'});
$.each(main, function(i, e){
var item = $('<div />', {
class:'item',
html:'<div><img src="' + e.imageProject + '" class="img-responsive" alt="' + e.title + '"><h2>' + e.title + '</h2></div>' +
'<div class="content"><p>' + e.content + '</p></div></div>'
})
container.append(item);
});
container.appendTo($('main'));
The goal is to assign a HTML file to the variable content to be used inside the function where I generate the HTML structure. Is this posible?
Many thanks in advance.