diff options
author | Ariel Flesler <aflesler@gmail.com> | 2009-09-09 21:14:28 +0000 |
---|---|---|
committer | Ariel Flesler <aflesler@gmail.com> | 2009-09-09 21:14:28 +0000 |
commit | d1285504fb636a077ae5b1e53e35959cc7faebc7 (patch) | |
tree | 15271c5670399017b72ef45198015fb1ee3c9849 /src/attributes.js | |
parent | aadc268abf555f0f1cc7c5bc05d0dc73b35cb705 (diff) | |
download | jquery-d1285504fb636a077ae5b1e53e35959cc7faebc7.tar.gz jquery-d1285504fb636a077ae5b1e53e35959cc7faebc7.zip |
jquery core: Closes #5189. Added a generic function to handle getting/setting key-value/setting a hash.
Diffstat (limited to 'src/attributes.js')
-rw-r--r-- | src/attributes.js | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/src/attributes.js b/src/attributes.js index c4c750092..6aecf085c 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 ) { |