jQuery: Set click from array loop

前端 未结 4 1242
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-15 02:21

I have a series of divs in a pattern of header/body, where a click on the header will show the body in question.

This all happens with .click initialized on page ready..

4条回答
  •  南方客
    南方客 (楼主)
    2021-02-15 02:40

    Check the scope of your "Area" variable. You're basically assigning a global variable so on the last iteration "Area" is scoped outside of the loop.

提交回复
热议问题