【问题标题】:How to change document.title when clicking a link?单击链接时如何更改document.title?
【发布时间】:2012-07-15 06:44:27
【问题描述】:

似乎不可能……也许这里有天才!

仅限 jquery

【问题讨论】:

标签: javascript jquery


【解决方案1】:

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

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

另外,出于好奇,您尝试过什么?

【讨论】:

    【解决方案2】:
    $(document).ready(function(){
     $('a').click(function(){
      $('head title').text('HelloWorld'); 
     });
    });
    

    可能需要这样的html

    <a href="#">Click here to change title</a>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-31
      • 1970-01-01
      • 2017-11-04
      • 1970-01-01
      相关资源
      最近更新 更多