I have multiple selects in a table and I want to be able to change the options of al the selects on a column when I change the option of the select on the first row. The problem is that the selects are added dynamically. I managed to do this by targeting the first select of each column by it's ID, but I'm looking for a way to do this for all elements at once.
This is the code I have for each column:
$('id-of-the-table-that-already-exists-on-page').on('change','id-of-the-first-select-on-each-column', function() {
var _value = $(this).val();
var selectId = $(this).attr("id").slice(0, -1);
$('*[id^="' + selectId + '"]').val(_value);
});
Is there a way to add a each function to target all first row selects, instead of targeting each select by it's id?