代码如下:
var addEvent = {
"action1": function() {
console.log('action1');
},
"act":function() {
console.log('act');
alert('act');
},
"do":function() {
console.log('do');
},
"doing":function() {
console.log('doing');
},
"btn-primary":function(){
console.log("btn-primary");
$('.myhide').show();
},
"myhide":function(){
console.log('我是隐藏后再显示的内容哦!');
}
}
$(function(){
$("body").on('click','[class]',function(e){
for(var cn in addEvent){
if($(this).hasClass(cn)) {
addEvent[cn]();
}
}
return false;
})
})