JQuery 'trigger (' click ') `does not work on operation if item is not displayed

I have an element that clicks on it event triggers, clicks on the <input style="display:none" type="file"/> element. this item is hidden ( display:none ). In this browser: Chrome, IE, FireFox it works (the trigger starts), but this is not the case in Opera and Safari. Is there any special thing for problem browsers (Opera and Safari)? Is there any walk?

Thank you very much!

here is the event code

 $('#add_cv').click(function(){ $('#add_cv_input').trigger('click'); }); 
+4
source share
2 answers

Ok, I found this workaround, I set the css element to:

 visibility: hidden; position: absolute; top:0; 

It works on every browser above. I will be more than happy to hear any other decisions.

+10
source

As an alternative to display: none use the following:

 position: absolute; top: 0; left: -9999px; 
+5
source

Source: https://habr.com/ru/post/1439625/


All Articles