Change Title With Javascript

后端 未结 4 1117
失恋的感觉
失恋的感觉 2020-12-20 11:30

How can I modify the existing title to the document with Jquery as mouseover title change like that on facebook title link.

4条回答
  •  不知归路
    2020-12-20 12:00

    I'll extend on these other answers, this code should do it in entirety, just be sure to change the class in the selector, and the new Title Text.

    (function(){
        var oldtitle;
        jQuery('a.yourlink').hover(
            function () {
               oldtitle = document.title;
               document.title = 'Your New Title';
            },
            function () {
                document.title = oldtitle;
            }
        );
    })();
    

    Here is a jsfiddle demo I made that changes the text of the object, rather than the window title: http://jsfiddle.net/MpZGf/1/

提交回复
热议问题