what is the difference between calling function with () and without(). When we assign functions to variables?
<p>I want to know what is the difference , when we call function with round Brackets() and without brackets (). Suppose if i have a function like</p>

<pre><code>function($) {

    var hideAnswers = function() {

        $('#faqGrid tr td').each(function(){

            var $td = $(this);
            $td.children('div .answer').hide();

        }); //end of $('#faqGrid tr td').each(fn)

    }; //end of var hideAnswers = function() {}

    var showMessage = function(message){

        alert(message);

    }; //end of var showMessage = function(){}

    hideAnswers();  //working
    hideAnswers;    // not working

}(jQuery); // end of  function($) {
</code></pre>

<p>The second one <strong>hideAnswers;</strong> is now working in this case. Also i want to ask when we assign function to variable and when we don't?</p>

<p>Also suppose if i have a button, on click of which i want to call this function then how can we call it Like</p>

<pre><code>&lt;input type="button" onclick = hideAnswers(); /&gt;  // is it right?
</code></pre>

<p>And what if i also want to pass value to this function on my xhtml page. Like</p>

<pre><code>&lt;input type="button" onclick = showMessage("what is your name "); /&gt;  // is it right?
</code></pre>

<p>Thanks</p>
