Can you set event.data with jquery trigger

后端 未结 11 563
轻奢々
轻奢々 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:02

    As far as I know, the same dataObject that you defined with the original :

    $('selector').on('eventName', dataObject , functionName)
    

    will be also sent when you use `$('selector').trigger('eventName').

    you can also pass parameters (like other mentions in their answers) but those parameters will be additional arguments (you will still have the dataObject you set in the .on() function).

提交回复
热议问题