Level 1
I think what you can do is just animate with jquery and change the attribute inside the animation as this https://stackoverflow.com/questions/6670718/jquery-animation-of-specific-attributes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have somehow managed to change the logo (img src) on scroll with JS ofcourse. Now I am stuck, how can i add transition while the logos are changing ('src').
Here is the code: Html:
<a class="navbar-brand mx-auto" href="/">
<div class="navbar-brand-img">
<img src="img/logo/full.png" class="animate" alt="">
</div>
</a>
Javascript:
<script>
$(function () {
$(window).scroll(function () {
if ($(this).scrollTop() > 1000) {
$('.navbar-brand-img img').attr('src','img/logo/half.png');
}
if ($(this).scrollTop() < 1000) {
$('.navbar-brand-img img').attr('src','img/logo/full.png');
}
})
});
</script>
Css:
.navbar-brand-img img {
-webkit-transition: all 3s;
transition: all 3s;
}
Please or to participate in this conversation.