X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fattributes.js;h=6aecf085c44e7f4dfbdf131e1da12c96f6082876;hb=cf8c1249d1efbdaf4f4dd8d1a36bb803335f4ee8;hp=c4c75009205faedd4e2fa92f896696e19f222d77;hpb=96dd06ea50674c77de4a5d953c227bb54d9276af;p=jquery.git diff --git a/src/attributes.js b/src/attributes.js index c4c7500..6aecf08 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -1,34 +1,6 @@ jQuery.fn.extend({ attr: function( name, value ) { - var elem, options, isFunction = jQuery.isFunction(value); - - if ( typeof name === "string" ) { // A single attribute - if ( value === undefined ) { // Query it on first element - return this.length ? - jQuery.attr( this[0], name ) : - null; - } else { // Set it on all elements - for ( var i = 0, l = this.length; i < l; i++ ) { - elem = this[i]; - if ( isFunction ) - value = value.call(elem,i); - jQuery.attr( elem, name, value ); - } - } - } else { // Multiple attributes to set on all - options = name; - for ( var i = 0, l = this.length; i < l; i++ ) { - elem = this[i]; - for ( name in options ) { - value = options[name]; - if ( jQuery.isFunction(value) ) - value = value.call(elem,i); - jQuery.attr( elem, name, value ); - } - } - } - - return this; + return access(this, name, value, true, jQuery.attr); }, addClass: function( value ) {