The existence and parameter problems of function in the jquery library of JavaScript _jquery

Source: Internet
Author: User
Tags md5 jquery library

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 ();


Related Article

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.