i have a dynamically generated table and after the table loads i need to print few selected rows in console based on checkbox.
The table is populated with data from backend.
<div class="row" style="margin-left : 8px !important;margin-right : 8px !important">
<table class="table table-bordered fixed_headers" id="Device_list">
<thead>
<tr>
<th> </th>
<th>IPADDRESS</th>
<th>DEVICE NAME</th>
<th>STATUS</th>
<th>BACKUP</th>
</tr>
</thead>
<tbody id = "all_device">
{% for item in Device_list %}
<tr>
<td><input type="checkbox" name="device_check"/></td>
<td>{{ item['ipaddress'] }} </td>
<td>{{ item['name'] }} </td>
<td>{{ item['status'] }} </td>
{% if item['backup'] == 'no_backup' %}
<td>{{ item['backup'] }}</td>
{% else %}
<td><a href="{{ url_for('backups_texts',path = item['backup']) }}">Backup</a> </td>
{% endif %}
</tr>
{% endfor %}
</tbody>
<input type="submit" id="bt" value="Show Table Data" />
</table>
function myfunc() {
console.log ("inside my function");
var valuelist = [];
$('#all_device tr').each(function() {
$(this).find("input[name='device_check']:checked").each(function() {
var values = [];
$(this).closest("td").siblings("td").each(function() {
values.push($(this).text());
});
valuelist.push(values.join(", "));
});
});
console.log("(" + valuelist.join("),(") + ")");
}
$(document).ready(function() {
$("#bt").click(function() {
myfunc();
});
});
Kindly help with accessing the table row content.