Alex Rivera | Logout

Is this how you define a function in jQuery?

Asked 2009-05-25T18:22:54.243
52

Is this how you define a function in jQuery?

$(document).ready( function () {
    var MyBlah = function($blah) { alert($blah);  };
 });

Now to call the function I do:

MyBlah('hello');
Edit
Report

1 Answer

16

No.

You define the functions exactly the same way you would in regular javascript.

//document ready
$(function(){
    myBlah();
})

var myBlah = function(blah){
    alert(blah);
}

Also: There is no need for the $

answered 2009-05-25T18:25:55.890

Your Answer