Changing the page title with Jquery

Ilya Medvedev picture Ilya Medvedev · Aug 24, 2011 · Viewed 113.1k times · Source

How to make dynamic changing <title> tag with jquery?

example: adding 3 > symbols one by one

> title
>> title
>>> title

Answer

Gazler picture Gazler · Aug 24, 2011
$(document).prop('title', 'test');

This is simply a JQuery wrapper for:

document.title = 'test';

To add a > periodically you can do:

function changeTitle() {
    var title = $(document).prop('title'); 
    if (title.indexOf('>>>') == -1) {
        setTimeout(changeTitle, 3000);  
        $(document).prop('title', '>'+title);
    }
}

changeTitle();