JavaScript onclick requires two clicks

前端 未结 8 1131
执笔经年
执笔经年 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:10

    e.style.display represents the style of the element defined by the style attribute, it does not give you the computed style. to get the computed style use

    if (window.getComputedStyle(e,null).getPropertyValue("display") == 'block){
    

提交回复
热议问题