Can you set event.data with jquery trigger

后端 未结 11 571
轻奢々
轻奢々 2020-12-12 16:27

With jQuery .on() you can pass an optional parameter to set the event data. Can you do this with trigger as well?

11条回答
  •  难免孤独
    2020-12-12 17:03

    Yes. The documentation says:

    .trigger( eventType [, extraParameters] )

    Note the difference between the extra parameters we're passing here and the eventData parameter to the .bind() method. Both are mechanisms for passing information to an event handler, but the extraParameters argument to .trigger() allows information to be determined at the time the event is triggered, while the eventData argument to .bind() requires the information to be already computed at the time the handler is bound.

提交回复
热议问题