Add function values to addClass, removeClass, toggleClass, text, and removeAttr

This commit is contained in:
Yehuda Katz 2009-12-09 20:57:19 -08:00
parent 4e9fed3b16
commit da51cd0e43
4 changed files with 93 additions and 28 deletions

View file

@ -32,6 +32,12 @@ if ( !jQuery.support.htmlSerialize ) {
jQuery.fn.extend({
text: function( text ) {
if(jQuery.isFunction(text)) {
return this.each(function() {
return jQuery(this).text( text.call(this) );
});
}
if ( typeof text !== "object" && text !== undefined ) {
return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
}
@ -87,7 +93,7 @@ jQuery.fn.extend({
}
}).end();
},
append: function() {
return this.domManip(arguments, true, function(elem){
if ( this.nodeType === 1 ) {