change favicon with jquery

this one is good if you have a favicon that just wont change, this will make sure it changes with jquery.

(function() {
    var link = document.querySelector("link[rel*='icon']") || document.createElement('link');
    link.type = 'image/x-icon';
    link.rel = 'shortcut icon';
    link.href = 'http://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico';
    document.getElementsByTagName('head')[0].appendChild(link);
}());

example

Demo

Other Items in js
Page Views

This page has been viewed 140 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹