What's wrong with the code delay pressing the button?

Good day, there is a button on the website with a pop-up window, the id of the button medium_box_link.
there is jquery code:
$(document).ready(function(){
setTimeout(function(){
$("#medium_box_link").trigger('click');
 }, 5000);
 })

You need to wait 5 seconds after entering the website a pop up this pop-up. Took this code from Internet but it doesn't work. jQuery connected. Please tell me, what's the problem? just in case the link to the website red button "the mega event".
June 14th 19 at 21:00
1 answer
June 14th 19 at 21:02
Solution
That method trigger can be used for items with an already installed handler events of interest (in this case click). And if Your handler is written in the onclick parameter of the tag - nichrome will work, too.
Options:
1. Hang on a normal button handler method .on('click', function(){
//....
});
2. Use addEventListener()
3. For the correct simulation of the events use the recommended jquery.simulate
Choose any option.
As there tell, not to ask more about these... nobska the nuances:)
Thank you! You know what noob, so I chose the complexity of the intern) - urban_Daugherty22 commented on June 14th 19 at 21:05

Find more questions by tags JavaScript