let title = 'Nothing is impossible for a willing mind'
定义实现标题滚动的函数
function titleChange () {
const keywords = title.split('') // 将标题转为字符串数组
const firstChar = keywords.shift() // 取出标题中第一个字符
keywords.push(firstChar)
title = keywords.join('')
document.title = title
}
开启定时器
setInterval(fn, delay)
完整代码
let title = 'Nothing is impossible for a willing mind'
function titleChange () {
const keywords = title.split('')
const firstChar = keywords.shift()
keywords.push(firstChar)
title = keywords.join('')
document.title = title
}
setInterval(titleChange, 500)