How can I modify the existing title to the document with Jquery as mouseover title change like that on facebook title link.
Asked
Active
Viewed 5.0k times
24
-
You can see an example jQuery code [here](http://jquery-howto.blogspot.com/2012/12/change-document-tab-title-jquery.html). – Uzbekjon Jan 29 '13 at 14:27
-
possible duplicate of [Changing the page title with Jquery](http://stackoverflow.com/questions/7173596/changing-the-page-title-with-jquery) – kapa Jul 08 '14 at 08:46
-
Possible duplicate of [How to dynamically change a web page's title?](https://stackoverflow.com/questions/413439/how-to-dynamically-change-a-web-pages-title) – vrintle Nov 09 '18 at 17:05
4 Answers
11
With javascript. jQuery won't help you here:
document.title = 'New Title';
You can insert that into a jQuery mouseover callback function if you want.

Paul
- 139,544
- 27
- 275
- 264
7
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/
-
It looks like `oldTitle` will be out of scope when it's needed the second time. – bbg Jul 16 '11 at 05:09
-
This won't work. oldtitle won't exist when the 2nd function is called. You have to move oldtitle up to a higher scope or save it somewhere else. – jfriend00 Jul 16 '11 at 05:09
-
1wouldn't it be better to wrap the lot in a function and not have to attach extra 'properties' to the document like here - http://jsfiddle.net/aranm/gUsnC/2/ – Aran Mulholland Jun 13 '12 at 04:38