jquery custom event
by basecss
HTML
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<button class="btn">click me to trigger custom event</button>
JavaScript
$(function(){
// 监听一个自定义事件
$('.btn').on('custom.event', function(event, text){
$(this).text(text);
});
$('.btn').on('click', function(){
var i = 0;
// 触发自定义事件, 还可以传递更多的参数用于事件监听器回调逻辑中
$(this).trigger('custom.event', 'custom event triggered');
});
});