Reputation: 18798
Considering the following, how can I enable a disabled element on click?
$("element").click(function(){
//enable element
});
Upvotes: 1
Views: 2103
Reputation: 253436
The best I could come up with is:
$('label').click(
function(){
$(this).next(':disabled').removeAttr('disabled');
});
Since the disabled element itself doesn't, at least in Chrome 8/Ubuntu 10.10, respond to click events.
This does assume, of course, that the label
precedes the disabled element, and doesnt', in its current form, check that the label corresponds to the next disabled element.
Edited to revise the approach, so clicking on the label
affects only the relevant input
:
$('label').click(
function(){
var relevantInput = $(this).attr('for');
$('#' + relevantInput)
.removeAttr('disabled');
});
Upvotes: 3