I have a html table that I am dynamically generating from a JSON file. This table contains rows with a dropdown list and a checkbox. If the default value in the dropdown list is selected the checkbox should be disabled otherwise it should be enabled. I believe the following code should do what I want.
$(function() {
$('td select').change(function () {
console.log(this.id);
$(this).closest('tr').find('input[type="checkbox"]').prop('disabled', $( 'select option:selected' ).val()=='Default');
}).change();});
However, when I run it in my code only the first row of the table demonstrates the functionality I'm looking for. Because the table is dynamically generated from a JSON I don't believe a loop is an option. Similar questions have been asked here but they won't work for dynamically generated tables. The fiddle attached below is similar to what I am trying to implement and it seems as though my logic is the same. If anyone could point me in the right direction I would be grateful.
Aucun commentaire:
Enregistrer un commentaire