How to do Initial Caps With Javascript/jQuery

Try using css property text-transform:capitalize; for the breadcrumb.

Mostlikely in you case it should be,

.breadcrumb1 a {
   text-transform: capitalize;
}

My first thought is:

breadcrumb += "<span>" + s[i].substring(0,1).toUpperCase() + s[i].substring(1) + "</span>";

But @Esailija's answer is much easier. Reference:

  • toUpperCase().

You could use css:

span.breadcrump {
    text-transform: capitalize;
}

I recently wrote this helper method to do this for me:

function autocase ( text ) {
    return text.replace(/(&)?([a-z])([a-z]{2,})(;)?/ig,function ( all, prefix, letter, word, suffix ) {
        if (prefix && suffix) {
            return all;
        }

        return letter.toUpperCase() + word.toLowerCase();
    });
}

It takes into account things such as &trade;

Edit: To use this method, simply pass it a string, and it will return the string auto cased. It does not work on html strings.

//...
document.getElementById('breadcrumb1').innerHTML=url;
function autocase ( text ) {
    return text.replace(/(&)?([a-z])([a-z]{2,})(;)?/ig,function ( all, prefix, letter, word, suffix ) {
        if (prefix && suffix) {
            return all;
        }

        return letter.toUpperCase() + word.toLowerCase();
    });
}
$("#breadcrumb1 a").text(function(i,text){
    return autoCase(text);
});