我不完全确定这个问题,但这似乎是你想要的行为:
http://jsfiddle.net/cHrSG/
命名空间是
之后
事件,而不是之前,因此格式为
event.namespace
,
the jQuery docs have a thorough read here
. 如果您在代码周围交换它们具有预期的效果,那么至少我认为这是您期望的最好结果,我可以从这个问题中看出:
jQuery('#content div.child')
.bind('a.a',function(){alert('a-child');})
.bind('b.a',function(){alert('b-child');})
.bind('c.a',function(){alert('c-child');});
jQuery('#content div.parent')
.bind('b.a',function(){alert('b-parent');})
.bind('c.a',function(){alert('c-parent');});
jQuery('a.btn-a')
.click(function(){
jQuery('#content div.child').trigger('a.a');
});
jQuery('a.btn-b')
.click(function(){
jQuery('#content div.child').trigger('b.a');
});
jQuery('a.btn-c')
.click(function(){
jQuery('#content div.child').trigger('c.a');
});â