Can you set event.data with jquery trigger

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

    You can do this way:-

    Example

      //Create a new jQuery.Event object without the "new" operator.
      var e = jQuery.Event("click");
    
      // trigger an artificial click event
      jQuery("body").trigger( e );
    

    You can pass event.data too with the same approach. Refer this Event Object

提交回复
热议问题