jQuery: Set click from array loop

前端 未结 4 1243
爱一瞬间的悲伤
爱一瞬间的悲伤 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:59

    It's a JavaScript thing; it's not jQuery related. What you're doing is creating a closure, but you're not understanding properly how they work.

    You might want to read up on http://blog.morrisjohns.com/javascript_closures_for_dummies, especially Examples 5, 6, and 7.

提交回复
热议问题