[jQuery] Enable/Disable extension

[jQuery] Enable/Disable extension


Am I re-inventing the wheel here? I just want a simple extension to
test if a control is enabled and to set jQuery objects quickly.
If this has already been done, could you point me to it? If not,
please offer comments on my approach.
Thanks, Dave
jQuery.fn.enabled = function(enableIt) {
//sets object(s) to enabled/disabled or returns the enabled state
of the first element
if (enableIt == null || enableIt == undefined) //nothing passed,
just return state of first element
{
return !($(this).attr("disabled") == "disabled");
}
else //setting element(s)
{
$(this).each(function(){
if (enableIt)
{
$(this).removeAttr("disabled");
}
else
{
$(this).attr("disabled", "disabled");
}
});
return this; //keep chain
}
};