Skip to content

Instantly share code, notes, and snippets.

@binde77
Created October 12, 2013 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save binde77/6950112 to your computer and use it in GitHub Desktop.
Save binde77/6950112 to your computer and use it in GitHub Desktop.
Javascript: set <title> from <h2> tag
//set <title> tag according to page title as displayed in <h2>
$('document').ready(function(){
var pagetitle = $("h2").text();
var pathname = window.location.pathname;
if(pathname.indexOf('/en/') > -1){
var titletag = pagetitle + ' | ENGLISH TITLE';
}
else {
var titletag = pagetitle + ' | ITALIAN TITLE';
}
$("title").text(titletag);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment