Skip to content

Instantly share code, notes, and snippets.

@jitter
Created February 2, 2011 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jitter/807092 to your computer and use it in GitHub Desktop.
Save jitter/807092 to your computer and use it in GitHub Desktop.
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;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment