js通过判断实现 link rel="icon" 的改变

if (workLength > 0) {
    var link = document.querySelector('link[rel*="icon"]') ||document.createElement('link')
    link.type = 'image/x-icon'
    link.rel = 'shortcut icon'
    link.href = 'http://www.stackoverflow.com/favicon.ico'
    document.getElementsByTagName('head')[0].appendChild(link)
}

即可实现切换,那些看着数字变化的其实都是图片,不要怕怕哦

发布了58 篇原创文章 · 获赞 0 · 访问量 5103

猜你喜欢

转载自blog.csdn.net/qq_40295815/article/details/104265348