- // Determine the position of an element within
- // the matched set of elements
- index: function( elem ) {
- // Locate the position of the desired element
- return jQuery.inArray(
- // If it receives a jQuery object, the first element is used
- elem && elem.jquery ? elem[0] : elem
- , this );
- },
-
- attr: function( name, value, type ) {
- var options = name, isFunction = jQuery.isFunction( value );
-
- // Look for the case where we're accessing a style value
- if ( typeof name === "string" ) {
- if ( value === undefined ) {
- return this.length ?
- jQuery[ type || "attr" ]( this[0], name ) :
- null;
-
- } else {
- options = {};
- options[ name ] = value;
- }
- }
-
- // Check to see if we're setting style values
- for ( var i = 0, l = this.length; i < l; i++ ) {
- var elem = this[i];
-
- // Set all the styles
- for ( var prop in options ) {
- value = options[prop];
-
- if ( isFunction ) {
- value = value.call( elem, i );
- }
-
- if ( typeof value === "number" && type === "curCSS" && !exclude.test(prop) ) {
- value = value + "px";
- }
-
- jQuery.attr( type ? elem.style : elem, prop, value );
- }
- }
-
- return this;
- },
-
- css: function( key, value ) {
- // ignore negative width and height values
- if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 )
- value = undefined;
- return this.attr( key, value, "curCSS" );
- },
-
- text: function( text ) {
- if ( typeof text !== "object" && text != null )
- return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
-
- var ret = "";
-
- jQuery.each( text || this, function(){
- jQuery.each( this.childNodes, function(){
- if ( this.nodeType != 8 )
- ret += this.nodeType != 1 ?
- this.nodeValue :
- jQuery.fn.text( [ this ] );
- });
- });
-
- return ret;
- },
-
- wrapAll: function( html ) {
- if ( this[0] ) {
- // The elements to wrap the target around
- var wrap = jQuery( html, this[0].ownerDocument ).clone();
-
- if ( this[0].parentNode )
- wrap.insertBefore( this[0] );
-
- wrap.map(function(){
- var elem = this;