Dynamically Change Favicon Using jQuery

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