Home > front end >  $(document). Ready (function () {}) this statement in the function () {} in after ready () what mean
$(document). Ready (function () {}) this statement in the function () {} in after ready () what mean

Time:10-09

The code is as follows:

<script type="text/javascript">
The $(document). Ready (function () {
$(" # loginForm "). The validate ({
Rules: {
ValidateCode: {remote: "${pageContext. Request. ContextPath}/servlet/validateCodeServlet"}
},
Messages: {
Username: {required: "please fill in the user name."}, password: {required: "please fill in the password."},
ValidateCode: {remote: "authentication code is not correct.", the required: "please fill out the captcha."}
},
ErrorLabelContainer: "# messageBox,"
ErrorPlacement: function (error, element) {
Error. AppendTo ($(" # loginError "). The parent ());
}
});
});

</script>

Questions as follows:

1, $(document). Ready (function () {}) this statement in the function () {} in after ready () what meaning be?
2, $(" # loginForm "). The validate ({
Rules: {
ValidateCode: {remote: "${pageContext. Request. ContextPath}/servlet/validateCodeServlet"}
},
Messages: {
Username: {required: "please fill in the user name."}, password: {required: "please fill in the password."},
ValidateCode: {remote: "authentication code is not correct.", the required: "please fill out the captcha."}
},
ErrorLabelContainer: "# messageBox,"
ErrorPlacement: function (error, element) {
Error. AppendTo ($(" # loginError "). The parent ());
}
})

in $(" # loginForm "). The validate is what meaning, validate is a function of the standard? Next () these are all its parameters, corresponding function statements that he where is it? And in which the label is the error message? I got no ID for loginError element in the page?

CodePudding user response:

1, ready () is a jquery inside a method, which (function ()) said the ready pass a callback function/method parameter
2, in the same way, validate is also a method, should be mounted on the jQuery method of a tool, all () the contents can be said as the parameters of this method, the corresponding function should be you introduce the jQuery plugin, errors also must be combined with you introduce that plug-in can know clearly

CodePudding user response:

1 said the document to the ready state trigger function in brackets

2 is a function of JQuery, is a parameter in brackets
Parameters that can refer to the following
https://blog.csdn.net/ALLsharps/article/details/6886476

CodePudding user response:

Just like the meaning of English said: ready (function () {}) is the web page when ready, call the function () {} anonymous functions.
Validate is a jquery plugin to do check forms, the inside of the () is its parameters, define the form validation rules of each input box.
Error messages in the event of validation failures from that plug-in source code, plug-in there are dynamically creating HTML tags in the source code, similar to append the label after you input
  • Related