diff --git a/lms/templates/courseware/courseware.html b/lms/templates/courseware/courseware.html index 15e4dead9a..761237fd76 100644 --- a/lms/templates/courseware/courseware.html +++ b/lms/templates/courseware/courseware.html @@ -39,19 +39,22 @@ $(function(){ $(".ui-accordion-header a, .ui-accordion-content .subtitle").each(function() { - var wordArray = $(this).text().split(" "); + var elemText = $(this).text().replace(/^\s+|\s+$/g,''); // Strip leading and trailing whitespace + var wordArray = elemText.split(" "); var finalTitle = ""; - if ($.isEmptyObject(wordArray)) { + if (wordArray.length > 0) { for (i=0;i<=wordArray.length-1;i++) { finalTitle += wordArray[i]; if (i == (wordArray.length-2)) { finalTitle += " "; + } else if (i == (wordArray.length-1)) { + // Do nothing } else { finalTitle += " "; } } - $(this).html(finalTitle); } + $(this).html(finalTitle); }); });