Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger click jquery not working

Tags:

I'm figuring out why this simple script is not working:

jQuery.noConflict(); jQuery(document).ready(function() {     jQuery('.next_button a').trigger('click'); }); 

noConflict is necessary because I also load prototype/scriptaculous in this page.

If I replace .trigger('click') with another function (es: .css(...) this works well. Only triggering seems to go broken.

like image 828
Riccardo Avatar asked May 03 '11 09:05

Riccardo


People also ask

Why jQuery trigger is not working?

You need to trigger the default click method, not the one by jQuery. This can be done by adding the default click option within a click event of jQuery using this . This is how the JavaScript looks. It basically creates the event when the DOM is ready, and clicks it intermediately, thus following the link.

What is trigger click in jQuery?

trigger( "click" ); As of jQuery 1.3, . trigger() ed events bubble up the DOM tree; an event handler can stop the bubbling by returning false from the handler or calling the . stopPropagation() method on the event object passed into the event.

How to trigger form in jQuery?

jQuery submit() Method The submit event occurs when a form is submitted. This event can only be used on <form> elements. The submit() method triggers the submit event, or attaches a function to run when a submit event occurs.

What does trigger do in jQuery?

The trigger() method triggers the specified event and the default behavior of an event (like form submission) for the selected elements. This method is similar to the triggerHandler() method, except that triggerHandler() does not trigger the default behavior of the event.


1 Answers

How can I simulate an anchor click via jquery? Check this link and see this answer by Stevanicus.

$('a#swaswararedirectlink')[0].click();

like image 128
A Bright Worker Avatar answered Oct 04 '22 17:10

A Bright Worker