My JS knowledge is quite close to null. I am working on a website and I made some custom tabs. I need the first one to be open by default. Yesterday I added this script to my JS code ( I am working in wordpress by the way) and it worked fine!
<script>
document.getElementById("defaultOpen").click();
</script>
Yesterday it was working but today I didn't move a thing and no matter what I do it won't work again. In the console I get this error:
Get Uncaught TypeError: Cannot read property 'click' of null
Any ideas what could this be? Why was it working in the past and not now? I tried open in a different browser or to clear the cache but it keeps happening and I am curious on why it worked before and not now and how can I fix this. Does anyone have any suggestions please? I'm a JS noob.
EDIT: None of the past questions these peopel asked solved my problem. So it is not a duplicate.