How can I solve this? Tried also with the jQuery(document).ready(function(){...}) but without success. You will need to use a workaround. Thanks for posting this. This might happen when the event is not attached to an anchor tag but to some other element, like a div. You just need to put a small timeout event before doing .click() like this : jQuery’s .trigger('click'); will only cause an event to trigger on this event, it will not trigger the default browser action as well. The .trigger() function cannot be used to mimic native browser events, such as clicking on a file input box or an anchor tag. Change the .click code to: The .on() event is related to the .click() event but by not directly binding the event and moving to delegates we can tell jQuery how to handle a click event raised from an element known as btnNew wherever it is on the body. This will not only trigger the jQuery event handlers, but also follow the link and change the current page. link.trigger() vs .triggerHandler(). XML. Fix When jQuery Click Event Is Not Working On Touch Devices. JQuery OnClick Method is bound to an element or selector on page ready/load. Questions: It wants a file path from me in the src section of this library, but I want to write the link of the picture, but it doesn’t accept it. There are four differences between .trigger() and .triggerHandler().triggerHandler() only triggers the event on the first element of a jQuery object..triggerHandler() cannot be chained. while the user is typing. The fix is easy enough, simply bind the OnClick event to the parent of the elements you want to be able to click on. jQuery There are four differences between .trigger() and .triggerHandler(), For more information see the triggerHandler documentation. Thank you very very much! Then we’ll put a .click function to handle the event. The code that calls the Trigger should go after the event is called. Really, you could argue that the fix should be the new default for using on click events in general, as it would completely remove the possibility of on click not working after appending HTML. The issue is very easily fixed though, understanding why this happens first is a good place to start. Using these two APIs, you can programmatically create an event that behaves exactly as if someone has actually clicked on a file input box. You need to use jQuery('#bar')[0].click(); to simulate a mouse click on the actual DOM element (not the jQuery object), instead of using the .trigger() jQuery method. JavaScript JQuery OnClick Method is bound to an element or selector on page ready/load. Additional parameters to pass on to the event handler. javascript – How to get relative image coordinate of this div? See my demo: http://jsfiddle.net/8AVau/1/. With this technique, .trigger() can be used to notify other sections of code that an application specific event has happened.