Passing parameters to event listeners / handlers

前端 未结 8 1350
清酒与你
清酒与你 2020-12-06 06:40

How do you pass parameters / variables through event listeners? I\'ve overcome this problem fairly effectively using anonymous functions; which is an incredibly simple solut

8条回答
  •  借酒劲吻你
    2020-12-06 07:08

    If I were looking for this functionality, and I often do, I would make tempThumb a Class that carried the url property. then:

    MyThumbClass(event.target).url //in the MouseEvent.CLICK handler
    

    Strong typing, easy access, clean syntax, low complexity.

提交回复
热议问题