使用 jQuery 添加标题标签?

发布于 2024-08-29 03:14:36 字数 217 浏览 1 评论 0 原文

我希望我的标题标签如下所示:

我的网站 - 页面名称

我想在前面添加 我的网站 - 部分,这样我就不必键入它在我制作的每一个新页面上。因此,我在页面上实际拥有的标题标签将是:

<title>Name of Page</title>

这可能吗?

I want to have my title tag look like this:

My Website - Name of Page

I want to prepend the My Website - part so that I don't have to type it on every new page I make. So the title tag that I actually have on the page would be:

<title>Name of Page</title>

Is this possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

¢蛋碎的人ぎ生 2024-09-05 03:14:36

我认为一个 jquery 脚本可以做到这一点:

$(document).ready(function() { 
    document.title = "Your WebSite Name - " + document.title; 
}); 

我建议在页面级别而不是客户端执行此操作......

I think a jquery script to do it would be:

$(document).ready(function() { 
    document.title = "Your WebSite Name - " + document.title; 
}); 

I would recommend doing this at the page level instead of client side though...

饭团 2024-09-05 03:14:36

似乎其他人已经尝试过但无法使用 jQuery,但你可以使用 document.title, http://hancic.info/change-page-title-with-jquery

Seems others have tried and not been able to do is using jQuery but you can use document.title, http://hancic.info/change-page-title-with-jquery

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文