Examples of differences between JQuery and submit () in JS

Source: Internet
Author: User

Examples of differences between JQuery and submit () in JS

This article mainly introduces the differences between JQuery and submit () in JS. For more information, see

ASP. NET Server controls use this JS Code for sending back:

The Code is as follows:

Var theForm = document. forms ['form1'];

If (! TheForm ){

TheForm = document. form1;

}

Function _ doPostBack (eventTarget, eventArgument ){

If (! TheForm. onsubmit | (theForm. onsubmit ()! = False )){

TheForm. _ EVENTTARGET. value = eventTarget;

TheForm. _ EVENTARGUMENT. value = eventArgument;

TheForm. submit ();

}

}

 

The problem we encountered today is that we want to assign a value to a hidden domain before the server-side control returns a value to the server.

 

Therefore, an event is added using the submit ([data], fn]) method of JQuery, but it does not work.

 

I tried $ ("form: first"). submit () and found that the event function could be triggered.

 

What's going on? After checking the information, we found that the native function void submit () of js does not trigger the submit event. This is why the above Code contains

The Code is as follows:

If (<span style = "color: #006600">! TheForm. onsubmit | (theForm. onsubmit ()! = False </span> )){

...

}

 

This sentence.

 

Write the Add event

The Code is as follows:

$ ("Form: first") <span style = "color: #006600">. get (0) </span>. onsubmit = function (){

...

};

 

You can.

 

In addition, events added using JQuery's submit ([data], fn]) can be triggered with $ (). submit.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.