2012-07-15 55 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> 
相關問題