Or even more simply:

$.fn.checked = function(b) {
    return b == undefined || b ?
        this.attr('checked', b) :
        this.removeAttr('checked');
};

This would handle the return statements nicely, along with non-boolean
values (in case someone  still wants to pass in the word "checked",
for example).

--John

> $.fn.checked = function(b) {
>     if( typeof b == 'boolean') {
>         if(b) {
>           this.attr('checked, 'checked');
>         } else {
>           this.removeAttr('checked');
>     } else {
>        return this.attr('checked');
>     }
> }
>
> Could then be categorized within DOM/Attributes, as it aligns nicely
> with the rest of the set/get methods.

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to