i only know basic javascript and not even basic jquery, but i would like to know something that is probably really trivial in jquery.
I would like a very simple example of how to create a function in a js file and execute that with a dom class parameter(like .sample) from my main script. Something like :
$('.sample').execute(200);
How would you go about writing this type of function in the jquery js file ? Simply put, i want an example to better understand how $() is used with jquery methods and how .sample is passed as a parameter to execute() and how it’s used in it.
If I’ve understood your question correctly you are basically asking how to write a jQuery plugin.
The basic idea is this:
This can then be called as you showed in your question:
You can learn alot more on the jQuery Plugin Authoring page. If you want to actually understand what the above code means, and what actually happens, it’s probably worth getting to grips with JavaScript before looking at jQuery.