I’ve a checkbox that enable or disable a select element
Actually I use this simple piece of code that works fine.
$("#filtri").change(function(){
if ($("#menuContinenti").attr("disabled")) {
$("#menuContinenti").removeAttr("disabled");
} else {
$("#menuContinenti").attr("disabled", "disabled");
}
});
Is this the best way or is there something like a .toggle() function to switch between disabled/enabled?
You should use
.propfor disabled:UPDATE: didn’t realize the current property value is an argument to the function; this version is even cleaner:
UPDATE: ES2015