I have this example simple code to enable and disable a form according to a select elements value.
$("#myoptions").change(function(){
var item = $("#myoptions option:selected").val();
$("#target").html(item );
if(item == "empty"){
$("#addForm").children().attr("disabled","disabled");
/*else{
$("#addForm").children().removeAttr("disabled");
} */
}
});
The problem is it can be disabled but when trying to enable again it doesn’t work and prevents the code from executing.
The enabling code is commented have a look at this: http://jsfiddle.net/BbZw8/3/
The
elsestatement was inside theifstatement – the problem was simply due to an incorrectly placed closing brace. Other than that the code worked.Try this:
Example fiddle