Programmatical click on -tag not working in Firefox

前端 未结 5 624
醉话见心
醉话见心 2020-12-02 17:57

I have a problem with the click()-function from jquery. I create a -element with document.createElement(\'a\') and want call

5条回答
  •  不思量自难忘°
    2020-12-02 18:39

    Add the element to the DOM before triggering the click:

    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
    

    This worked for me in all the major browsers

提交回复
热议问题