Hi, I just have a small doubt in jQuery.. I have a js file, sampleFunc.js, which has this code: I'm calling this js from my html file like this: All I need is: 1. Send a couple of parameters through sampleFunc and receive them at the JS file.. Should I replace the $ in the "function($)" with the 2 parameter?? Can someone help me? PS: Its the first time I'm seeing a jQuery script So please dont bother my silly doubts..
no. the (function($) { ... })(jQuery); is called a closure and is there to ensure that your function will play nicely if jquery goes into compatibility mode. it binds/aliases $ to jQuery for the scope only w/o affecting the global ownership of $ passing parameters to the function needs to take place under the domready call to the function itself. $("#samp").sampleFunc(someArgs, arg2); Code (javascript): modify the function declaration in the .js file to nominate the arguments and do whatever needs to be done with them, just as usual.
Thanks Dimitar, for your reply.. Just tried out a few more things after going thro the official docs and the code is working fine.. Thanks again!