X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fattributes.js;h=fd3e38acec80d174f82cbe44313a646d6ad8065b;hb=0636dffc2481c14368464a22ffa1bd8017da2a26;hp=a76695b661d16c9aa4077182a3ead23544a17696;hpb=c4e653237f258ce618ad5a9ec677917166fbed16;p=jquery.git diff --git a/src/attributes.js b/src/attributes.js index a76695b..fd3e38a 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -136,7 +136,7 @@ jQuery.fn.extend({ }, val: function( value ) { - if ( value === undefined ) { + if ( !arguments.length ) { var elem = this[0]; if ( elem ) { @@ -209,9 +209,10 @@ jQuery.fn.extend({ val = value.call(this, i, self.val()); } - // Typecast each time if the value is a Function and the appended - // value is therefore different each time. - if ( typeof val === "number" ) { + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + } else if ( typeof val === "number" ) { val += ""; }