Search code examples
jquerytitlebreadcrumbs

Change the page title to the last item in my breadcrumb with jquery


I am using a bread crumbing and need to change the page title to whatever the text is in the last breadcrumb. Is this possible?

<div class="span12">
<div class="breadcrumb clearfix">
<span itemtype="http://data-vocabulary.org/Breadcrumb" itemscope="">
 <a itemprop="url" title="domain" href="mydomain.com">
  <span itemprop="title">Home</span>
 </a>
</span>
  <span class="arrow-space">></span>
 <span itemtype="http://data-vocabulary.org/Breadcrumb" itemscope="">
    <a itemprop="url" title="tape" href="/collections/tape">
     <span itemprop="title">tape</span>
    </a>
 </span>
<span class="arrow-space">></span>
  <span itemtype="http://data-vocabulary.org/Breadcrumb" itemscope="">
    <a itemprop="url" title="black" href="/collections/tape/black">
      <span itemprop="title">black</span>
    </a>
</span>
</div>
</div>

Not sure how to go about this


Solution

  • document.title = $("span:last", ".breadcrumb").text() ​​