(^92) ❘ CHAPTER 4 MANIPULATING CONTENT AND ATTRIBUTES
$('input[name="documentAttributeMarx"]:first')
.attr('checked', true);
return getCheckbox();
};
$('button#documentSetAttribute').click(
function(event)
{
event.preventDefault();
var input = getCheckbox();
input
.attr('disabled', true)
.parent('li')
.addClass('disabled');
}
);
$('button#documentRetrieveAttribute').click(
function(event)
{
event.preventDefault();
var input = getCheckbox();
alert('Disabled: ' + input.attr('disabled'));
}
);
$('button#documentRemoveAttribute').click(
function(event)
{
event.preventDefault();
var input = getCheckbox();
input
.removeAttr('disabled')
.parent('li')
.removeClass('disabled');
}
);
}
);
The preceding example demonstrates how you use jQuery’s attr() and removeAttr() methods to set
the disabled attribute on the selected radio element. The preceding example produces some-
thing similar to what you see in Figure 4-1, upon clicking the Set Attribute button.
http://www.it-ebooks.info
elliott
(Elliott)
#1