2012-07-15 42 views
-3

似乎不可能......也许这里有个天才!如何在点击链接时更改document.title?

jquery only

+0

“也许有一个天才在这里!” - 被合法地吐出来。对你好,萌芽! – tekknolagi 2012-07-15 06:47:29

+0

与@Blender一起,我很想知道您尝试了什么。 – tekknolagi 2012-07-15 06:47:55

+0

此外,http://stackoverflow.com/questions/1500554/is-there-a-way-using-jquery-to-change-the-document-title-after-the-page-has-lo?rq=1 – tekknolagi 2012-07-15 06:48:13

回答

3

不需要jQuery。我只使用它,因为它更容易绑定事件:

$('#your-link').on('click', function(event) { 
    event.preventDefault(); 
    document.title = 'The new title'; 
}); 

另外,出于好奇,你有什么尝试?

0
$(document).ready(function(){ 
$('a').click(function(){ 
    $('head title').text('HelloWorld'); 
}); 
}); 

,可能需要HTML这样

<a href="#">Click here to change title</a> 
相关问题