Im trying to change the logo in my header based on how far I've scrolled on the page. I've tried to use things such as Midnight.js, but I need to render a whole different logo on scroll, not just change the color of the picture. I've tried doing it like this, but it doesn't work.
<script>
window.onscroll = function() {myFunction()};
function myFunction() {
if (document.body.scrollTop > 500 || document.documentElement.scrollTop > 500) {
var source= "images/whitelogo.png";
} else {
var source= "images/blklogo.png";
}
}
</script>
<h1 id="myP" ><a href="index.html" ><img alt="logo" src=source; style="height:2.8em" /></a></h1>
Thanks for your help!!!