public
Last active

  • Download Gist
textFast.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
jQuery.fn.textFast = function(text) {
if (jQuery.isFunction(text)) {
return this.each(function(i) {
var self = jQuery(this);
self.text(text.call(this, i, self.text()));
});
}
if (typeof text !== "object" && text !== undefined) {
return this.empty().append((this[0] && this[0].ownerDocument || document).createTextNode(text));
}
return jQuery.textFast(this);
};
 
jQuery.textFast = function(elems) {
var ret = "",
elem;
 
for (var i = 0; elems[i]; i++) {
elem = elems[i];
// this part is new.
ret += elem.textContent || elem.innerText || jQuery.text( elem.childNodes ); //to fix a scoping issue in IE6 with Sizzle.getText(elem.childNodes);
}
 
return ret;
};

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.