I'm struggling to get an Event Listener to self invoke a function and work correctly.
Although the following code runs the function, the Event Listener is not functioning as expected:
window.addEventListener("resize", (function () {
document.getElementById("divMenu").innerHTML = document.getElementById("divTop").offsetWidth
})())
This function is crucial for setting a dynamic CSS style necessary for website formatting. The "resize" function must be executed upon loading. Should I combine this into one self-invoking function, or create a separate Self-Invoking Function to call on the Event Listener?