Search code examples
javascriptjquerytitle

Changing the page title with Jquery


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

example: adding 3 > symbols one by one

> title
>> title
>>> title

Solution

  • $(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();