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.