[英]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.