I am working on a JavaScript code that is used to create a basic news page with a filter from a mySQL database. The code generates the heading, main content, and date created for each news item. I now need to add a "read more" link at the bottom of each news item, with the link being the same as the heading link but displaying as "read more".
Here is the updated and functioning code:
var base_href = '/go/media~';
function makeTable(data) {
var tbl_body = "";
$.each(data, function (index, row) {
var tbl_row = "";
$.each(row, function (k, v) {
if(k == 'heading' && 'id' in row) {
v = '<h2><a class="news" href="' + base_href + row.id +'">' + v + '</a></h2>';
}
tbl_row += "<div class='row'><div class='col-md-8 col-md-offset-2'>"
+ v + " </div></div>";
});
tbl_footer = '<a href="' + base_href + row.id + '">read more</a>';
tbl_body += "<div class='non-white-media'>" + tbl_row + tbl_footer + "</div>";
});
return tbl_body;
}