New Function disableToggle to toggle disable on and off

New Function disableToggle to toggle disable on and off similar to slideToggle

/*********************
Function:disableToggle
author:Mukesh
License: Void of any license
**********************/
$.fn.disableToggle = function() {
if(($(this).attr("disabled")=="disabled") ($(this).attr("disabled")==true))
{
$(this).removeAttr("disabled");
}
else
{
$(this).attr("disabled","disabled");
}
};

This function can be called as

$("#element-id").disableToggle();

where element_id is the id of the element.
For e.g.,

$("#edit-name").disableToggle();

Comments