Dynamically Change Favicon Using jQuery

By July 1, 2016March 17th, 2017Blog, Javascript, jQuery, Snippets
Allure Web Solutions Code Snippet

Changing a favicon dynamically (on demand) is surprisingly easy. It takes just one line of jQuery code. However we want to make it into a function, so it takes 3 lines. And here they are…

function changeFavicon(src) {
    $('link[rel="shortcut icon"]').attr('href', src)

And this is how you use it…


Super easy, right?


Mike Doubintchik

Author Mike Doubintchik

More posts by Mike Doubintchik

Leave a Reply