0

How to call jQuery function from normal JS function? ( A + B Sample needed)

So I need a jQuery function adding varA to varB. And a JS function which could call that jQuery function sending varA and varB to It and reciving result.

Rella
  • 65,003
  • 109
  • 363
  • 636

3 Answers3

2

jQuery functions are normal javascript: jQuery is just a file that includes a bunch of extremely well-written and useful javascript functions.

You can view the (100% javascript) source for the latest release here.

Jeff Sternal
  • 47,787
  • 8
  • 93
  • 120
1

jQuery functions are normal javascript functions.

So, you just call it like a "normal" function like in the following example using jQuery's trim().

    function isStringEmpty(str){
                             // jquery function
        return str!==null && jQuery.trim(str).length > 0;
    }
    alert(isStringNullorEmpty("hello")); //alerts false
    alert(isStringNullorEmpty("")); //alerts true
David Murdoch
  • 87,823
  • 39
  • 148
  • 191
  • This post is old and I'm not talking about the main subject but : your function `isStringEmpty` should be named `isStringNotEmpty` w/ this implementation. Just saying. – Ludovic Guillaume Dec 18 '14 at 10:14
0

A jQuery function is a normal JavaScript function.

 function myFunction () {
     function_name(); // and / or
     object.property_name();
 }

 myFunction();
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335