jQuery: receive extraParameters from triggerHandler()

前提是你 提交于 2019-12-08 16:07:18

问题


   $('<span>test</span>')
    .change(function(e){console.log(e.data);})
    .triggerHandler('change',{foobar:1});

I'm doing it wrong or it's bugged?

Thanks ;)


回答1:


The extra data is passed as argument to the handler:

$('<span>test</span>')
.change(function(e, data){console.log(data);})
.triggerHandler('change',{foobar:1});

The documentation also says that it has to be an array, though it works with one object too.



来源:https://stackoverflow.com/questions/6348572/jquery-receive-extraparameters-from-triggerhandler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!