Reputation: 335
Okay, Uber Noob back on the questions!
Context: Building a Timeline, not date specific
Problem: Adding numbers to HTML output via jquery
Have not started attacking the problem ( not expecting a full and easy answer ) so I am really looking for a starter. Thanks in advance.
var dragger = $j('div.dragger');
var totaldays = $j(dragger).width() / 245;
var totaldaysround = Math.ceil(totaldays);
var listdays = $j('span.totaldays').append('Estimated period of ' + totaldaysround + ' Days')
// Total days echoed out in html tags
var html = [];
for (i = 0; i < totaldaysround; i++) {
html.push('<span class="fldi day">Day</span>'); //just need to pipe in some numbers here
}
$j('span.days').append(html.join(''))
Upvotes: 0
Views: 407
Reputation: 3566
Try with string concatenation:
for (i = 0; i < totaldaysround; i++) {
html.push('<span class="fldi day">Day ' + i + '</span>');
}
Upvotes: 1
Reputation: 235962
Should it be as simple as this ?
for (i = 0; i < 5; i++) {
html.push('<span class="fldi day">Day ' + i + ' </span>');
}
http://www.jsfiddle.net/n5rCU/
Upvotes: 2