I’m trying to set the next input in the dom to read only but am going wrong.
Heres the jQuery:
$('select.expense-code').change(function(e) {
// If expense code is travel mileage
if ($(this).val() == '5') {
// Set miles to read only
var currentRowAmount = $(e.target).next("input.amount");
currentRowAmount.attr('readonly', true);
}
});
Heres that part of the dom:

I’ve tried just setting the bg colour etc but nothing works, I’m sure its down to the .next() bit but need a prod in the right direction. Console.log() just gives you [].
Thanks in advance
.next()grabs the immediate next sibling, it doesn’t search for anything, the filter argument is just to make sure that the next sibling is within the filter.from the docs:
Since you already have id on the target, you can just do:
The one liner: