I have been trying to change the a href of a branding image (in WordPress) located in the footer area with custom JavaScript, I think the image and the URL is defined here:
<!-- !Bottom-bar -->
<div id="bottom-bar" role="contentinfo">
<div class="wf-wrap">
<div class="wf-container-bottom">
<div class="wf-table wf-mobile-collapsed">
<div id="branding-bottom" class="wf-td"><a href="https://change this url.com/"><img class=" preload-me" src="default.jpg" srcset="default.jpg 240w, default.jpg 240w" width="240" height="60" sizes="240px" alt="default" /></a></div>
<div class="wf-td">
<div class="wf-float-left">
</div>
</div>
I have tried some solutions but nothing seems to work properly.
<script>
document.getElementById("branding-bottom").href = "https://www.newpageurl.html";
</script>
In other posts, this code was successfully used to change href and the image itself but I can only see this error when I try to load the page.
Uncaught TypeError: Cannot set property 'href' of null at https://change this url.com/:366
I am thankful for every help I can get this is still somewhat new and confusing for me. Thank you!