I have a <table> with a <td> where I would like to replace the text - using javascript.
<table class="table">
<tbody>
<tr>
<td id="53ffaf3e436872c452020000">
2014-08-16T11:00:00.000+02:00
</td>
</tr>
</tbody>
</table>
I receive from the server a new_dates object of key/value pairs that I loop through:
Coffeescript version:
last_dates.map (last_date) ->
for key of last_date
console.log key + " has the date: " + last_date[key] # 53ffb262436872c499b90f00 has the date: 2014-08-16T11:00:55.000+02:00
$("##{key}").text = "#{last_date[key]}"
Javascript version:
last_dates.map(function(last_date) {
var key, _results;
_results = [];
for (key in last_date) {
console.log(key + " has the date: " + last_date[key]); // 53ffb262436872c499b90f00 has the date: 2014-08-16T11:00:55.000+02:00
_results.push($("#" + key).text = "" + last_date[key]);
}
return _results;
});
The above code is supposed to find all the id's from key's, and replace their text values with value's. My code, however, does not work. What am I doing wrong?