Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 985559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:11:02+00:00 2026-05-16T05:11:02+00:00

Correct me if I am wrong, but seems to me jQuery event handling is

  • 0

Correct me if I am wrong, but seems to me jQuery event handling is completely separate from the javascript event handling. I know that the order of executing jQuery and javascript event handlers themselves is undefined, but can the assumption be made that all javascript handlers will execute before jQuery ones?

In the example given in an answer to this question that seems to be the case.

Also, is there any preference on executing inline javascript event handlers in respect to bound ones?

For clarification, I am asking all of this because I encountered a problem where I have an inline event handler on onClick event of an <a> element that calls the submit() method of an enclosing form. Just before submitting the form, I want to dynamically add some hidden inputs to the form. Right now I am doing this:

        var preSubmit = function preSubmit()
        {
            // add inputs
        }

        var oldSubmit = form.submit;
        form.submit = function newSubmit()
        {
            preSubmit();
            oldSubmit.call(form, arguments);
        }

But I’m really wondering if there is a more elegant way and I really need some clarification on this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:11:02+00:00Added an answer on May 16, 2026 at 5:11 am

    I’m not sure about the specs but I presume that event handlers are just queued in the same order as you define them. Inline handlers are defined right in the DOM node so nothing else can go earlier.

    The most elegant way is to write all your JavaScript in an unobtrusive way, i.e., keep it separated from HTML (you appear to be mixing programming styles). Whatever, you can intercept form submission by attaching an onsubmit handler to the form:

    $("form").submit(function(){
        // Do stuff
        return true;
    });
    

    Update

    I’ve done some testing and it appears that an onsubmit handler attached to a form via jQuery does not get triggered when you call the DOM’s submit() method somewhere else. Here’s a workaround:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head><title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript"><!--
    jQuery(function($){
        $("a").each(function(i, a){
            a.onclick = function(){ // Remove previous handlers
                alert("I will no longer submit the form");
                $(this).closest("form").submit();
            };
        });
        $("form").submit(function(){
            alert("I'll take care myself, thank you");
            $("input[name=foo]").val("Another value");
            return true;
        });
    });
    //--></script>
    </head>
    <body>
    
    
    <form action="" method="get">
        <input type="text" name="foo" value="Default value">
        <a href="javascript:;" onclick="document.forms[0].submit()">Submit form</a>
    </form>
    
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

correct me if im wrong, but isn't distributed SCMs for OS projects while centralized
Please correct me if I am wrong, but is one complex query less expensive
The following code produces wrong and inconsistent output with gcc (4.1.2 20080704) but correct
I have a WCF service that accepts requests from JQuery. Currently, I can access
I am currently building a browser extension that injects javascript/jquery into certain pages, and
Example user input: PA1 9 //correct PJ1 9 //wrong, error printed Invalid row because
Correct me if anything is wrong. Now when we use Spring DAO for ORM
Correct me If Im wrong. public class Person{ List<Cars> myCars; //Get and Set }
Correct me If I am doing wrong, I have just started to check WCF
I believe ( correct me if i am wrong ), according to the C#

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.