$(this) OR event.target OR var input = $(this)

前端 未结 4 1059
刺人心
刺人心 2020-12-31 23:33

jQuery is currently providing me with a fun introduction to Javascript after 12 years of surviving happily without. I\'m at the stage where I\'m trying to learn as much as I

4条回答
  •  一整个雨季
    2021-01-01 00:16

    this and event.target are not always the same. this refers to the element you assigned the listener to ( in this case the '#a_button' ). event.target however is the element that actualy triggered the event, which can be a childnode of #a_button.

    So $(this) is the thing you are looking for.

    See reference: http://api.jquery.com/event.target/

提交回复
热议问题