samedi 10 février 2018

Running multiple setIntervals when the number of runs required is unknown Javascript

I have multiple text boxes in my code (the number of text boxes is variable -> meaning it will change over time depending on what the user wants, but the setInterval Javascript code must still work irrelevant of the number of text boxes). A sample of the HTML code is the following:

  <input type="text" class="textBox" name="firstname" value="Mickey">
  <br>

I want to run a setInterval on each of the text boxes and perform some task on each. The problem is how would you run multiple setIntervals when the number of text boxes is not fixed? Meaning they can be added or removed at will, but the Javascript setInterval() must still work for each text box (depending on how many there are during that specific run).

setInterval(function(){someFunction();}, 5);

How would you go about this please?

Thank you




Aucun commentaire:

Enregistrer un commentaire