用传参实现trigger的回调:

点击btn1触发btn2的click事件并执行trigger中传入的回调方法

<body>
<input type="button" id="btn1" value="btn1">
<input type="button" id="btn2" value="btn2">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$('#btn1').on("click",function(){
$("#btn2").trigger("click",[function (a){alert("this is callback"+a);},"执行回调"]);
})
$('#btn2').on('click',function(ev,callbk,agu){
        alert("这是btn2的事件");
if(agu="执行回调"){
callbk.call(this,agu);
}
}
</script>
</body>
05-11 11:08