JS CallMultipleFunctions | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

JS CallMultipleFunctions

I'd like to use CallMultipleFunctions in JS script to animate multiple items simultaneously, but I can't seem to get the format right in order for the code to run. Is CallMultipleFunctions the right code in this case, or is there another way to animate multiple items? (So far, I can only code animation for one item at a time.)

10th Jul 2017, 3:12 AM
Megan Marie Montez
Megan Marie Montez - avatar
5 Answers
+ 2
There's no CallMultipleFunctions built-in function in JS ^^ And you cannot simply run many functions really at same time... but you can do it fakely, by many ways... What's the code context of your needs of such function? Do them have arguments to pass, or not? And do them be functions or methods (attached to an object or not)? Anyway, for doing animation of multiples items, it seems to me that it will be a dew more efficient to have once animation function, in wich you do loops iterating items to animate and updating them without calling as many functions than you have items to animate ;P
10th Jul 2017, 5:18 AM
visph
visph - avatar
+ 2
Good attempt, but not at all what I was meaning ;) Among your mistakes: + your <br> tags are wrong spelling: they doesn't have any slash char (/), neither at start nor at end + your <div>s structure is quite surprising: one container for your 'fireflies' is ok, but why keeping some embed in others? + you put some unnecessary (and invalid, even if good autocorrected) semi colon (;) after some css declaration (after closing curly bracket) + your background-image definition is not valid at all, and so uneffective + the 'text-decoration:blink;' property/value shouldn't work on most browsers, but you can replace it with some css and/or js animation + providing a font-family name (at least a generic one) to the body would avoid using too much different fonts regarding the browser used (serif or sans serif: not always same default value) + your css can be improved, but I've assumed that you intentionnally set different background colours and shadows properties on differents fireflies (anyway, I've adapted them for corrected/cleaner html, and use relatives units to made it more responsive) + you missuse the .getElementById() method: you cannot pass more than once id value as argument (parameter), as you're trying to do, even you can think that's work, it doesn't: in fact, you're animating only the first 'firefly' <div> wich contains all the other ;P Anyway, in all cases, you'll benefits of much cleaner code write ^^ Check this cleaned/corrected/improved code (with responsive styling in bonus): https://code.sololearn.com/Wo18UwcR5aDk/ ... and let me know if you need more explanations/advices about it ;)
14th Jul 2017, 4:46 AM
visph
visph - avatar
+ 1
I'm trying to do that, too! Plz help!!!
10th Jul 2017, 3:15 AM
Andrés04_ve
Andrés04_ve - avatar
13th Jul 2017, 4:41 PM
Megan Marie Montez
Megan Marie Montez - avatar
0
No arguments to pass (I think, still learning terminology), just wanted to animate the group of boxes. I did as you suggested and tried using one function to animate the set as a group. I'm a little disappointed I couldn't make the boxes move in different directions, but I guess that becomes possible through other coding programs (maybe j-query? I haven't made it through all of the courses yet, just HTML, CSS, JS, and some of Python). Still a fun excercise overall.
13th Jul 2017, 4:46 PM
Megan Marie Montez
Megan Marie Montez - avatar