Can you set event.data with jquery trigger

后端 未结 11 565
轻奢々
轻奢々 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 16:49

    you can do this way

      
        ​
        $("#btn").bind("click",function(e) {
            var data2 = {type:"click",name:"Raptors",sport:"basketball"};
            $("#btn2").trigger(data2);
        });
        $("#btn2").bind("click",function(e) {
           console.log(e.name + " " + e.sport);
        });
    

提交回复
热议问题