Jquery: Setting/removing two attributes at once
javascript, jquery
Solution
obj.nextAll('.update')
.attr({
disabled: true,
hidden: true
})
.html('<option value="">----</option>');
According to @nnnnnn comment `.prop()` might be more appropriate than `.attr()`
i.e
obj.nextAll('.update')
.prop({
disabled: true,
hidden: true
})
.html('<option value="">----</option>');
DEMO for adding multiple attr
To remove
// from jQuery1.7, it can be a space-separated list of attributes.
obj.next('.update').html(data.list).removeAttr('disabled hidden');
DEMO for remove multiple attr
Problem
I am upcoming learner with jquery. Does anyone know how to give set two attributes at once that fit into the below example? For the moment I am only able to give it one attribute. My goal is to able to give two attributes to a select box 'disabled' and 'hidden' ``` obj.nextAll('.update').html('<option value="">----</option>').attr('disabled', true); ``` Same things goes for removing the attributes: 'disabled' and 'hidden' ``` obj.next('.update').html(data.list).removeAttr('disabled'); ```