adding multiple event listeners to one element

后端 未结 14 1467
夕颜
夕颜 2020-11-27 13:12

So my dilemma is that I don\'t want to write the same code twice. Once for the click event and another for the touchstart event.

Here is the original co

14条回答
  •  日久生厌
    2020-11-27 13:26

    This mini javascript libary (1.3 KB) can do all these things

    https://github.com/Norair1997/norjs/

    nor.event(["#first"], ["touchstart", "click"], [doSomething, doSomething]);
    

提交回复
热议问题