编程语言
首页 > 编程语言> > JavaScript 实现标题滚动效果

JavaScript 实现标题滚动效果

作者:互联网

JavaScript 实现标题滚动效果

实现步骤

    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)

标签:滚动,title,JavaScript,标题,keywords,const,titleChange,firstChar
来源: https://blog.csdn.net/m0_57835615/article/details/120602966