Resizing window requires refresh to trigger interactions written in jquery

Hello, Community

I’m facing an issue of custiom jquery not triggering on window resize like i have written custom jquery to open submenu on hover but when i resize the window the submenu do not appear on hover. And then i have to refresh to get the submenu open on hover.

I have tried window.load and window.resize but its not working