--UPDATE--
here is my jsfiddle:
https://jsfiddle.net/18g8np7b/
I have a jquery datatable (www.datatables.net) where one of the columns has a dropdown menu. I assigned a change listener to my select dropdown. My problem is the listener only activates if I the select dropdown on the first row is selected. My table currently has 20 rows, but the change listener/event only activates if the select on the top row is changed. Here's my table:
<table id="projects_table" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
<thead>
<tr>
<th>Project Code</th>
<th>Project Name</th>
<th>Project Manager</th>
<th>Client</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{{#each projects}}
<tr>
<td>{{projectcode}}</td>
<td>{{projectname}}</td>
<td>{{projectmanager}}</td>
<td>{{client}}</td>
<td>
<select class="form-control" id="actions">
<option selected>Select action</option>
<option>View Details</option>
<option>Export to CSV</option>
</select>
</td>
</tr>
{{/each}}
</tbody>
</table>
Here's my .js file:
$("#actions").change(function() {
alert('change!!'); ////only works if there's a change in the select dropdown on the first row
console.log($(this).find("option:selected").text());
});
Can someone help?
Thanks in advance!