javascript - Why does the push of the array superimpose the previous ones?
阿神
阿神 2017-05-18 10:54:21
0
3
582


This is my click event. Why does it become new every time I add an element?

阿神
阿神

闭关修行中......

reply all(3)
我想大声告诉你

...Your arr is in the event and is a new arr every time. .

左手右手慢动作

Because you initialize arr to new data every time var arr = [];
You should initialize arr on the click method

phpcn_u1582

Put var attr= []; outside the function and promote it to a global variable, and you should be fine.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template