diff --git a/jquery.expander.js b/jquery.expander.js index 85280a5..98329e6 100644 --- a/jquery.expander.js +++ b/jquery.expander.js @@ -79,8 +79,13 @@ rCloseTag = /<\/(\w+)>/g, rLastCloseTag = /(<\/[^>]+>)\s*$/, rTagPlus = /^(<[^>]+>)+.?/, + rMultiSpace = /\s\s+/g, delayedCollapse; + var removeSpaces = function(str) { + return $.trim( str || '' ).replace(rMultiSpace, ' '); + }; + var methods = { init: function() { this.each(function() { @@ -104,8 +109,8 @@ moreClass = o.moreClass + '', lessClass = o.lessClass + '', expandSpeed = o.expandSpeed || 0, - allHtml = $.trim( $this.html() ), - allText = $.trim( $this.text() ), + allHtml = removeSpaces( $this.html() ), + allText = removeSpaces( $this.text() ), summaryText = allHtml.slice(0, o.slicePoint); // allow multiple classes for more/less links