title: jQuery .click() does not work in Safari
body: <p>I have seen several similar posts with solutions that seemed to have worked for those people, but I CANNOT get this to work.</p>
  
  <p>I am using <a href="http://tutorialzine.com/2013/05/mini-ajax-file-upload-form/" rel="nofollow noreferrer">http://tutorialzine.com/2013/05/mini-ajax-file-upload-form/</a> in my project. It works PERFECTLY, in all browsers, except in Safari the "BROWSE" button does not open a file dialog. The following code exists in script.js (which is included for the plugin to work):</p>
  
  <pre><code>$('#drop a').click(function(){
      // Simulate a click on the file input button
      // to show the file browser dialog
      $(this).parent().find('input').click();
  });
  </code></pre>
  
  <p>The .click() does not fire in Safari. I have tried the solution as per <a href="https://stackoverflow.com/questions/12925153/jquery-click-works-on-every-browser-but-safari">jQuery .click() works on every browser but Safari</a> and implemented</p>
  
  <pre><code> $('#drop a').click(function(){
      var a = $(this).parent().find('input');
      var evObj = document.createEvent('MouseEvents');
      evObj.initMouseEvent('click', true, true, window);
      a.dispatchEvent(evObj);
  });
  </code></pre>
  
  <p>But then I get the error that <code>dispatchEvent is not a function</code>. I then did some research on this, and tried the jQuery.noConflict() route, but this did not resolve the error. Also, I use a LOT of jQuery in my main file and I cannot have the noConflict() mode activated for the entire page. There is also no reason that the jQuery should be conflicting with anything as I am only using jQuery and normal javascript and I am not using anything like prototype or angular. Does anybody know of another way to simulate a click in Safari? </p>
  
  <p><strong>UPDATE:</strong> Just FYI, I have added an <code>alert('test')</code> in the mentioned function (which triggers when "BROWSE" is clicked), and I do get the alert in Safari, but it is not simulating the click of the file input element, i.e: it is not openening the file dialog.</p>