I have status id defined in my div tag which is present in a phtml file .Now, I need to fetch its value into the seprate javascript file.
I have use jquery push method for this.
Code in phtml file :
<table class="abc">
<tbody id="checkboxes">
<tr class="r<?php echo $item['id']; ?><?php echo ($item['status_low']?' status-low':''); ?>">
<td><input type="checkbox" name="item" class="row" statusid="<?php echo $item['status_id']; ?>"</td>
<td><?php echo $item['id']; ?></td>
<td><?php echo $item['title']; ?></td>
</tr>
</tbody>
</table>
Code in Javascript File :
var selected = [];
$('#checkboxes input:checked').each(function() {
if ($(this).checked) {
selected.push($(this).attr('statusid'));
}
});
console.log(selected);
When I print selected array, I get a blank output .
Can anyone tell me where am I going wrong ?