hopefully a quick and easy one. I have a small sample of code (below) that when a class is found in the body, the page h1 title changes to another title. The project I'm working on needs lots of different templates, so I am using jquery to get this done.
The following works:
$(function() {
if ($(".Class").length > 0) {
$self = $('.header > h1')
$self.replaceWith( "<h1 class='classSomething'>" + "New Header
Title" + "</h1>" );
}
});
However, the page loads and then, the title changes which looks bad. Is there a way to make sure the title changes before we see any of the rendered page?
just to mention, I've tried $(window).load(function.... and this also does the same thing. Maybe a quick pause to let everything load and then, the page shows?