更改 HTML 页面图标?

发布于 2024-09-27 20:09:11 字数 68 浏览 0 评论 0原文

我有一个网页。我想更改按钮按下时的图标(这足以让我理解,但如果您能描述一种在单击按钮后为图标设置动画的方法,我会很高兴)。

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).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暖伴 2024-10-04 20:09:11

如果您确实想更改图标,jball 的解决方案将不起作用,因为浏览器似乎不会注意到现有 发生更改。您需要删除现有标签并插入一个新标签:

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

注意,这假设您的原始 favicon 链接具有 id favicon

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.

装迷糊 2024-10-04 20:09:11

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

检查此点击事件 。在该演示中,正在使用删除类。
addClass 函数就在那里。

如果需要,您可以使用 css 本身更改图像。

显示() 隐藏();函数用于显示隐藏 div 。你也可以使用这些

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文