Created
October 12, 2013 13:39
-
-
Save binde77/6950112 to your computer and use it in GitHub Desktop.
Javascript: set <title> from <h2> tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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