From a table row with two dropdowns, get selected value & which drop-down changed

后端 未结 2 474
Happy的楠姐
Happy的楠姐 2021-01-07 02:23

I am trying to update two cascading drop down inside a table there are many answers on SO for drop downs, but I was unable to find help on cascading updates

2条回答
  •  时光取名叫无心
    2021-01-07 02:48

    Assuming that you can't identify dropdwns by class or anything. Assuming that every time you change the value in a dropdown you want to update the other dropdown on the same row. Assuming that you have only two dropdowns per row:

    $('table').on('change', 'select', function() {
        var $current_dropdown = $(this),
            $other_dropdown = $(this).closest('tr').find('select').not(this);
    
        /// perform any task you need with current and other dropdown
    
    });
    

提交回复
热议问题