Re: [jQuery] Single Value Attributes

2006-10-03 Thread leandro nascimento camarg

I strongly suggest you to compare if a variable is equal to undefined using
the typeof unary operator, because if you, someday, dicide to get these
things work on IE 5, you can not compare to the undefined constant (?),
after all, it doesn't exist on IE 5.0. Compare like this one:

if(b || typeof b == 'undefined') { ...



John Resig wrote:
> 
> Sure, makes sense to me:
> 
> $.fn.checked = function(b) {
>if ( b || b == undefined )
>this.attr( "checked", "checked" );
>else
>this.removeAttr( "checked" );
> };
> 
> --John
> 

-- 
View this message in context: 
http://www.nabble.com/Single-Value-Attributes-tf2373768.html#a6618812
Sent from the JQuery mailing list archive at Nabble.com.


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


Re: [jQuery] Single Value Attributes

2006-10-03 Thread leandro nascimento camarg

What about you doing something like this:
$.fn.checked = function(b) {
b && this.attr('checked', 'checked') || this.removeAttr('checked');
}

but doing this we counting on both *attr* and *removeAttr* methods return
*true* on success (at least *attr* method).


John Resig wrote:
> 
> $.fn.checked = function(b) {
> if ( b )
> this.attr( "checked", "checked" );
> else
> this.removeAttr( "checked" );
> };
> 
> What do you think?
> 
> --John
> 

-- 
View this message in context: 
http://www.nabble.com/Single-Value-Attributes-tf2373768.html#a6618527
Sent from the JQuery mailing list archive at Nabble.com.


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