unsilder中的jq深入学习

//trigger
$('#foo').on('click', function() {
alert($(this).text());
});
$('#foo').trigger('click');
$('#foo').on('custom', function(event, param1, param2) {
alert(param1 + "\n" + param2);
});
$('#foo').trigger('custom', ['Custom', 'Event']);
var data = { id: 5, name: "张三" };
var events = {
"mouseenter": function(event){
$(this).html( "你好," + event.data.name + "!");
},
"mouseleave": function(event){
$(this).html( "再见!");
}
};
//为n5绑定mouseenter mouseleave两个事件,并为其传入附加数据data
$("body").on(events, "#n5", data);
posted @ 2016-12-31 16:36  莺哥  阅读(222)  评论(0编辑  收藏  举报