I am trying to write some JS in the <head>
of the document that changes some text after a date search is performed. Specifically, if the search did not show any results based on those dates.
This is via a code snippet section in the website builder, so I do not have direct access to the document. Only adding JS into <script><script/>
that is added to the <head>
of the doc.
I have tried:
<script>
document.getElementsByClassName("font-size-md")[0].setAttribute("id", "myId");
document.getElementById("myId");
myId.innerHTML = "Write Your Text Here";
</script>
This only modified the inner HTML after a refresh of the page.
I have also tried:
<script>
body = document.getElementsByTagName("body")[0];
body.onload = function() {
document.getElementsByClassName("font-size-md")[0].setAttribute("id", "myId");
document.getElementById("myId");
myId.innerHTML = "Write Your Text Here";
};
</script>
However, this seems to flat out not work.
Any suggestions?