I have a js function which looks like this
 function showProducts(){
    document.getElementById("shopList").innerHTML = "<ul><li>Test Text</li></ul>";
 }
It's a function that has to show an array of my products. I've made an div with id="shopList" in my html page
        <div id="shopList">
        </div>
But how can I call the function to show me the text in the div? It works when I use this as my body tag but I'm not allowed to write any js code in my html or to use onload or onclick. I'm trying to do it with listeners for almost 4 hours and I still did not find a solution. Could someone help me?
     <body onload="showProducts()">
    
<script>element that includes your JS (whether in an external file or inline) at the bottom of the body then you can just callshowProducts()directly without any event handlers because by the time it runs your div element will have been parsed (and thus can be accessed from JS). Or is your question really "How do I use.addEventListener()?"