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.

2
  • What do you mean by a "jQuery function"? Commented May 4, 2010 at 13:09
  • You don't need jQuery to add varA to varB - could you clarify why you want to use jQuery, or are you just looking for a "Hello, World" example? Commented May 4, 2010 at 13:14

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

Comments

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

1 Comment

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.
0

A jQuery function is a normal JavaScript function.

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

 myFunction();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.