I am not a programmer, I just a web designer with a bit of programmatic skills and I am asking for your help to learn a bit more about jquery/javascript.
I have a single function which is calling 2 different divs (test1 & test2)
myFunction ($("#test1"));
myFunction ($("#test2"));
I want to try to achieve instead something similar to
myFunction ($("#test1") $("#test2"));
Because I want to try to use one call, to call multiple divs. As well my problem is that my ipotetical myFunction should look like this:
myFunction (param1, param2){ if(typeof param2 == "undefined"){param2 = $(window)}; // do something}
I have no idea on how to create a multiple call to a function for doing the same action but on different elements, and with the fact that I could have multiple parameters, it doesn't make it easy for me.
Any suggestion on how to do it? or some resource where I could read for? thx, in advance! :)
myFunction($("#test1, #test2, #test3"));
Have a look at http://api.jquery.com/multiple-selector/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With