views:

125

answers:

3

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.

A: 

A jQuery function is a normal JavaScript function.

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

 myFunction();
David Dorward
+2  A: 

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
A: 

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