I want to create an extended disable/enable function in jQuery. This is working, but is this the best solution? Is each loop necessary?
$.fn.ariaDisabled = function (isDisabled) {
/// <summary>
/// Sets the disabled state.
/// </summary>
return this.each(function () {
var $item = $(this);
if (isDisabled === true) {
$item
.attr('disabled', 'disabled')
.attr('aria-disabled', 'true')
.addClass('disabled');
}
else {
$item
.removeAttr('disabled')
.removeAttr('aria-disabled')
.removeClass('disabled');
}
});
};
ariaDisabled
then it should only change the[aria-disabled]
attribute. – zzzzBov Jan 12 at 15:18