I have some python pulling data from Postgres, my HTML is iterating through the content and adding it to a table.
<tbody id="myTable">
{% for item in content %}
<tr>
<td class ="playerLink">{{ item[0] }}</td>
<td>{{ item[1] }}</td>
<td>{{ item[2] }}</td>
<td>{{ item[3] }}</td>
<td>{{ item[5] }}</td>
<td class ="linkId"></td>
</tr>
{% endfor %}
In playerLink I have an ID, 0,1,2,3, etc. What I am trying to do is use JQuery to append a link to linkId that is /destination/1/, /destination/2, etc. I have a funtion to search the table, then another that pulls the ID from the appropriate playerLink.
<script>
$(document).ready(function(){
$("#myInput").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#myTable tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
var id = [];
$('#mytable tr').each(function() {
var customerId = $(this).find(".playerLink").html();
console.log(customerId)
id.push(customerId);
console.log(id);
$('<a>',{
text: customerId,
href:'/playeroverview/' + customerId}
).appendTo('.linkId')
console.log('added link for ' + customerId);
});
I added in var id = []; to try and iterate through that, but I am failing at it. Any ideas?