X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fjquery%2Fjquery.js;h=f986d28f8a054fce0aa04eac91d6d620ee4fb329;hb=c8b7881c738f6949095029d75d847acc98b0afbc;hp=e46fc73865c83b517f3ffcb95d8f77f6aa2038b8;hpb=8b51bfbd3212a0bcaa35177056d0932b63eb268f;p=jquery.git diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index e46fc73..f986d28 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -411,10 +411,16 @@ jQuery.fn = jQuery.prototype = { * @result * @desc Sets title attribute from src attribute. * + * @example $("img").attr("title", function(index) { return this.title + (i + 1); }); + * @before + * @result + * @desc Enumerate title attribute. + * * @name attr * @type jQuery * @param String key The name of the property to set. * @param Function value A function returning the value to set. + * Scope: Current element, argument: Index of current element * @cat DOM/Attributes */ attr: function( key, value, type ) { @@ -430,12 +436,12 @@ jQuery.fn = jQuery.prototype = { } // Check to see if we're setting style values - return this.each(function(){ + return this.each(function(index){ // Set all the styles for ( var prop in obj ) jQuery.attr( type ? this.style : this, - prop, jQuery.prop(this, obj[prop], type) + prop, jQuery.prop(this, obj[prop], type, index) ); }); }, @@ -1256,10 +1262,10 @@ jQuery.extend({ return obj; }, - prop: function(elem, value, type){ + prop: function(elem, value, type, index){ // Handle executable functions if ( jQuery.isFunction( value ) ) - return value.call( elem ); + return value.call( elem, [index] ); // Handle passing in a number to a CSS property if ( value.constructor == Number && type == "curCSS" )