I'm trying to change the current logo of this website: https://moonstrategy.io/about/ from
https://moonstrategy.io/wp-content/uploads/2022/08/Moonstrategy_logo_vector_main_light_final.svg to https://moonstrategy.io/wp-content/uploads/2022/08/Moonstrategy_logo_vector_main_final.svg
I'm embedding this code in the webpage:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>document.getElementByClassName(".tgp-exclude small").src="https://moonstrategy.io/wp-content/uploads/2022/08/Moonstrategy_logo_vector_main_final.svg";</script>
I've also tried using different class names and while I'm pretty sure I tried all of them, I can either not seem to find the right one, or I am totally off with the code.
Help would be appreciated.
CodePudding user response:
- You included jquery, but you don't use jquery
- There is no such thing as
getElementByClassName
, there isgetElementsByClassName
getElementsByClassName
returns NodeList and you want only one element, usequerySelector
instead.
CodePudding user response:
nothing wrong here but I think the document.getElementsByClassName() returns an array of elements with the specified class name So it should be something like
document.getElementsByClassName(".tgp-excludesmall")[0].src="https://moonstrategy.io/wp-content/uploads/2022/08/Moonstrategy_logo_vector_main_final.svg";