Wait for a "3rd party" element to be appended to the DOM
That's a perfect job for MutationObserver.

new MutationObserver(function(mutations) {
    this.disconnect();
    // access the menu
    ........
}).observe($('.immediate-parent-of-the-menu')[0], {childList: true});

$button = $('#button');
$button.trigger('click');


The simplest case above works as-is if the menu is added in one mutation, otherwise you'd have to check each of the mutations array elements for addedNodes.