I have this Bootstrap snippet:
<ol class="breadcrumb">
<li><a href="#">Home</a></li>
<li><a href="#">Library</a></li>
<li class="active">Data</li>
</ol>
I'd like to use it to dinamically build the page <title>
, so I basically need to:
It should appear as:
Home / Library / Data
I'm almost there, but I'm stuck with this fiddle (I replaced <title>
with a <p>
, but the idea is the same): http://jsfiddle.net/G447V/
I don't know why, the separator is added also to the .breadcrumb
in the page (where slashes are CSS-generated)... And I don't know how toi say "add a slash to each, but not the last"
Please, any help?
Thanks in advance!
$( "title" ).text(function(){
var i = 0,
text = '';
$( ".breadcrumb li" ).each(function() {
if (i != 0) {
text += ' / ';
}
text += $(this).text();
i++;
});
return text;
});