Page 1 of 1

Change logo dynamically using jQuery

Posted: Sat Mar 02, 2024 12:24 am
by twuc

I want to change the brand logo dynamically, depending on the user logged in. But first I've uploaded an image, and have the following line in Client Scripts>Global>Pages with header and footer>Startup Script to test the principle:

        $(".img.brand-image.ew-brand-image").attr("src", "/images/myimage.png");

Firstly, even though I can see the script is executed in Console, there is no change to the image. Is this script correct?
Secondly, where's the best place to look to find out how to get the image name from the database to do this?


Re: Change logo dynamically using jquery

Posted: Sat Mar 02, 2024 9:51 am
by arbei

You need to set the src property, not the attribute, you may try .prop().