gpt4 book ai didi

javascript - 使用 jquery 更改选项卡标题?

转载 作者:行者123 更新时间:2023-11-30 14:15:35 24 4
gpt4 key购买 nike

我正在为一个 friend 在这个网站上工作,所以在页面刷新时随机选择一个字母星座(并且标签标题更改为对应),然后在晚上 9 点到午夜之间选择一个星座(称为“Gold Rocks”)加入页面上的任何一个..

我们希望标签标题能够读取当时页面上的任何内容 +“and Gold Rocks”.. 例如..

tab 之前在哪里..润唇膏鸡皮疙瘩工作

晚上 9 点到午夜之间应该是..润唇膏和金石鸡皮疙瘩和金石

我的代码哪里出错了?

是否可以只使用 Javascript?

<title></title>

+

<script>

//CHOOSES CONSTELLATION + CHANGES TAB !

var chooses = Math.floor(Math.random() * 2) + 1;
var title = $(document).prop('title');

//LIPBALM !

if (chooses == 1) {
document.write('<div class="lipbalm"><div class="lipbalm-l"><a href="http://sarahboulton.co.uk">L</a></div><div class="lipbalm-i"><a href="http://sarahboulton.co.uk">i</a></div><div class="lipbalm-p"><a href="http://sarahboulton.co.uk">p</a></div><div class="lipbalm-b"><a href="http://sarahboulton.co.uk">B</a></div><div class="lipbalm-a"><a href="http://sarahboulton.co.uk">a</a></div><div class="lipbalm-l2"><a href="http://sarahboulton.co.uk">l</a></div><div class="lipbalm-m"><a href="http://sarahboulton.co.uk">m</a></div></div>');

$(document).prop('title', 'Lip Balm');
}


//GOOSEBUMPS WORK !

if (chooses == 2) {
document.write('<div class="goosebumpswork"><div class="goosebumpswork-g"><a href="http://sarahboulton.co.uk">G</a></div><div class="goosebumpswork-o"><a href="http://sarahboulton.co.uk">o</a></div><div class="goosebumpswork-o2"><a href="http://sarahboulton.co.uk">o</a></div><div class="goosebumpswork-s"><a href="http://sarahboulton.co.uk">s</a></div><div class="goosebumpswork-e"><a href="http://sarahboulton.co.uk">e</a></div><div class="goosebumpswork-b"><a href="http://sarahboulton.co.uk">b</a></div><div class="goosebumpswork-u"><a href="http://sarahboulton.co.uk">u</a></div><div class="goosebumpswork-m"><a href="http://sarahboulton.co.uk">m</a></div><div class="goosebumpswork-p"><a href="http://sarahboulton.co.uk">p</a></div><div class="goosebumpswork-s2"><a href="http://sarahboulton.co.uk">s</a></div><div class="goosebumpswork-w"><a href="http://sarahboulton.co.uk">W</a></div><div class="goosebumpswork-o3"><a href="http://sarahboulton.co.uk">o</a></div><div class="goosebumpswork-r"><a href="http://sarahboulton.co.uk">r</a></div><div class="goosebumpswork-k"><a href="http://sarahboulton.co.uk">k</a></div></div>');

$(document).prop('title', 'Goosebumps Work');
}


</script>

+

<script type="text/javascript">

//GOLD ROCKS ! only between 9pm and midnight

var currentTime = new Date().getHours();

//if it is between 9pm and midnight
if (21 <= currentTime && currentTime < 24)
{
document.write('<div class="goldrocks"><div class="goldrocks-g"><a href="http://sarahboulton.co.uk">G</a></div><div class="goldrocks-o"><a href="http://sarahboulton.co.uk">o</a></div><div class="goldrocks-l"><a href="http://sarahboulton.co.uk">l</a></div><div class="goldrocks-d"><a href="http://sarahboulton.co.uk">d</a></div><div class="goldrocks-r"><a href="http://sarahboulton.co.uk">R</a></div><div class="goldrocks-o2"><a href="http://sarahboulton.co.uk">o</a></div><div class="goldrocks-c"><a href="http://sarahboulton.co.uk">c</a></div><div class="goldrocks-k"><a href="http://sarahboulton.co.uk">k</a></div><div class="goldrocks-s"><a href="http://sarahboulton.co.uk">s</a></div></div>');


$(document).prop('title', title+' and Gold Rocks');
}


</script>

http://sarahboulton.co.uk/kitchen.html

谢谢!

最佳答案

你可以简单地使用它:

$("head title")[0];

关于javascript - 使用 jquery 更改选项卡标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53611652/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com