Here is my code:
$("#product1 :checkbox").click(function(){
$(this)
.closest('tr') // Find the parent row.
.find(":input[type='text']") // Find text elements in that row.
.attr('disabled',false).toggleClass('disabled') // Enable them.
.end() // Go back to the row.
.siblings() // Get its siblings
.find(":input[type='text']") // Find text elements in those rows.
.attr('disabled',true).removeClass('disabled'); // Disable them.
});
How do I toggle .attr('disabled',false);
?
I can't seem to find it on Google.
$('#el').prop('disabled', function(i, v) { return !v; });
The .prop()
method accepts two arguments:
So in this case, I used a function that supplied me the index (i) and the current value (v), then I returned the opposite of the current value, so the property state is reversed.