JavaScript onclick requires two clicks

前端 未结 8 1149
执笔经年
执笔经年 2021-01-14 19:33

My problem is that when onclicktriggers the toggleNew function it\'s not executing but when I click the div a second time it\'s execut

8条回答
  •  灰色年华
    2021-01-14 20:08

    One way (for me the simplest way) to solve this is by counting clicks.

    For this purpose you set the new intiger variable click to 0 outside of your function toggleNew() and everytime you call your function you increase variable click for 1 like this:

    
    

提交回复
热议问题