jQuery function Parameter Pass
Use external variables in the function functions of jquery:
How to obtain I variable for
(i=0;i<3;i++) {
$.get ("/test.html", function (data) {
alert (i)
});
Use closure:
for (i=0;i<3;i++) {
(function (index) {
$.get ("/test.html", function (data) {
alert ( Index)
});
(i)
}
JavaScript, JQuery detects whether a function exists
The method for detecting whether a function exists in JavaScript is:
if (typeof $form. Validate = = ' function ') {
console.log (' This function exists ');
} else {
console.log (' This function does not exist ');
}
For example, you need to detect whether a MD5 method exists:
if (typeof window.md5 = = ' function ') {
//if pure in this method, the call to
MD5 (286);
}
To detect if a JQuery method exists, use the following methods:
if (Jquery.isfunction (jQuery.fn.rtFunction)) {
//If the method exists, invoke
JQuery (document). Rtfunction ();