views:

63

answers:

2

I have a webpage. I want to change the icon on button down (this would be enough for me to understand but I'd be glad if you'd describe a way to animate icon after button click).

A: 

http://api.jquery.com/click/

check this for click event . In that demo , remove class is using. addClass function is there.

You can change image using css itself if you want.

show() hide(); functions are there to show hide divs . you can use these too

zod
+4  A: 

If you do want to change the favicon, jball's solution will not work, because browsers don't seem to notice when an existing <link> changes. You need to remove the existing tag and insert a new one:

$(document).ready(function(){
    $('#favicon').remove();
    $('head').append('<link href="http://example.com/favicon.ico" id="favicon" rel="shortcut icon">');
});

NB This supposes that your original favicon link has the id favicon.

lonesomeday
Looks like you're right about needing to insert the new one. I would still use `$("#favicon")` instead of `$('link[rel=shortcut icon]')` unless there's some reason that doesn't work.
jball
@jball So would I -- changed. Thanks.
lonesomeday