Getting wordpress menu to open submenu on click on the main menu item

I’ve looked at many of the answers on this website but none of them are working on my website

I have the mobile version working with a workaround code

    window.addEventListener('load', function(){
    var menuItems = document.getElementsByClassName("menu-item-has-children");
    
    /*
     * Bij aanpassing mobiel menu, console.log(menuItems);
     * aanzetten, controleer de indexen van de mobiele menu items
     */
    // console.log(menuItems);
    
    menuItems[5].firstChild.removeAttribute("href");
    menuItems[5].firstChild.setAttribute("href", "#");
    menuItems[5].firstChild.addEventListener('click', (event) => {
        menuItems[5].firstChild.lastChild.click();
    });
    menuItems[6].firstChild.removeAttribute("href");
    menuItems[6].firstChild.setAttribute("href", "#");
    menuItems[6].firstChild.addEventListener('click', (event) => {
        menuItems[6].firstChild.lastChild.click();
    });
    menuItems[7].firstChild.removeAttribute("href");
    menuItems[7].firstChild.setAttribute("href", "#");
    menuItems[7].firstChild.addEventListener('click', (event) => {
        menuItems[7].firstChild.lastChild.click();
    });
    menuItems[8].firstChild.removeAttribute("href");
    menuItems[8].firstChild.setAttribute("href", "#");
    menuItems[8].firstChild.addEventListener('click', (event) => {
        menuItems[8].firstChild.lastChild.click();
    });
    menuItems[9].firstChild.removeAttribute("href");
    menuItems[9].firstChild.setAttribute("href", "#");
    menuItems[9].firstChild.addEventListener('click', (event) => {
        menuItems[9].firstChild.lastChild.click();
    });
});

But I want the desktop version to work the same way. The hover function can go if it’s in the way.

I’ve tried this code, but it doesn’t do the trick.

 if(clicked == false){
    document.getElementById("menu-item-has-children").style.display = "none";
    clicked = true;
}else if (clicked == true){
    document.getElementById("menu-item-has-children").style.display = "block";
    clicked = false;
}

The Satelite them is a real @#$ if it comes to the codes. I’ve looked and looked, but I can’t find the code that works the hover anywhere (probably tucked away in a file I’ll never find). But I’m using a child theme anyway, so I can add .php an .js files to overwrite anything. I just haven’t found anything that works. Does anyone have any idea of how I could get this on click show of the sub menu to work?