简体   繁体   English

单击链接并到达某个页面部分时,jQuery交换徽标

[英]jQuery swap logo when clicking a link and reaching a certain page section

I'm using a bootstrap based layout to build a website. 我正在使用基于引导程序的布局来构建网站。 It can be accessed here: http://ironsummitmedia.github.io/startbootstrap-grayscale/ 可以在这里访问: http : //ironsummitmedia.github.io/startbootstrap-grayscale/

Instead of the text-based logo I'm using a image. 我使用的是图像而不是基于文本的徽标。 Is there any way to swap the image with another one when a section of the menu is clicked on? 单击菜单的一部分时,是否可以将图像与另一图像交换? for example I want the logo to swap when you click on about and slide to that section. 例如,当您单击“关于”并滑到该部分时,我希望徽标交换。

thanks 谢谢

You can use getElementById(element).src to change the image source of the logo you're using as demonstrated in this jsfiddle (this is a javascript solution). 您可以使用getElementById(element).src来更改所使用徽标的图像源,如本jsfiddle所示 (这是一个javascript解决方案)。

If you must use jQuery, you can use .attr() to change the source. 如果必须使用jQuery,则可以使用.attr()更改源。 For example: $(element).attr("src","otherImage.jpg"); 例如: $(element).attr("src","otherImage.jpg");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 您如何通过单击链接转到网站的特定部分? - How do you go to a certain section of the website by clicking on a link? 尝试通过单击另一页面上的链接来访问页面上的某个部分时出错 - Error trying to access a section on a page by clicking on a link that is on another page 将鼠标悬停在特定的导航链接上时,如何交换具有不同徽标的页面徽标 - How Do I Swap Page Logo With Different Logo When Hovering Over Specific Nav Links 当到达页面顶部的某个元素时如何添加类并删除它? - How to add a class when reaching a certain element at the top of the page and delete it? 达到某个值时多次更改jQuery滑块的颜色 - Change the color of jQuery slider multiple times when reaching a certain value 单击链接时在导航中使用jQuery - 转到目标页面,然后滚动到页面的特定部分 - Using jQuery in navigation when link is clicked - go to target page, then scroll to a specific section of page 当单击链接然后使用jQuery重定向到该页面时,如何向页面添加内容? - How to add content to a page when clicking on a link and then redirect to that page using jQuery? 单击链接时的“ PHP重新加载”页面 - PHP Reload page when clicking link 单击链接时页面向下滚动 - Page scrolls down when clicking on a link 单击AngularJS中的链接时防止页面刷新 - Prevent page refresh when clicking a link in AngularJS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM