how can i trigger this function without using the form submit?
$('#myForm').submit(function()
{ ....
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.
Use Google Tag Manager's click trigger to fire tags based on click events. When an element is clicked on a page that matches the trigger conditions, Tag Manager will automatically populate values for any active click-based built-in variables.
and a trigger to execute the button1 click event handler. $("#button2"). bind("click", (function () { alert("Button 2 is clicked!"); $("#button1").
If you are trying to trigger an event on the anchor, then the code you have will work I recreated your example in jsfiddle with an added eventHandler so you can see that it works: $(document). on("click", "a", function(){ $(this). text("It works!"); }); $(document).
You could try -
$('#myForm').trigger('submit');
Working demo - http://jsfiddle.net/ipr101/KvwMb/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With