Greetings How can I implement the output of numbers from the array on a click? And the numbers need to display one by one and in order. Tried through cookies and php, but it turned out a hat.
Closed due to the fact that off-topic participants are Air , Igor , andreymal , Viktorov , aleksandr barakin 29 Dec '17 at 10:13 .
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
- βQuestions asking for help with debugging (β why does this code not work? β) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Air, Igor, andreymal, Viktorov, aleksandr barakin
- one"Tried" - where? - Igor
|
1 answer
var my_array = [ "1", "2", "3" ], $button = $('#button').html("1ΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ ΠΌΠ°ΡΡΠΈΠ²Π° ΠΈΠ· " + my_array.length), i = 0; function arrayStep() { if (i < my_array.length) { $('body').append("<p style=\"background-color:green;color:white\">" + my_array[i] + "</p>"); i++; } $button.html(i + "ΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ ΠΌΠ°ΡΡΠΈΠ²Π° ΠΈΠ· " + my_array.length); } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button id="button" onclick="arrayStep();">0ΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ ΠΌΠ°ΡΡΠΈΠ²Π° ΠΈΠ·</button> |