jquery自定义属性添加点击事件

html:

  `<button list-event="export_list">导出</button>`

js代码

/*A.call(B,x,y)

1、改变函数A的this指向,使之指向B;

2、 把A函数放到B中运行,x和y是A函数的参数。*/
var car_data = {
	init : function (){
		 //点击事件
		$('body').on('click', '*[list-event]', function(e){
			var othis = $(this), methid = othis.attr('list-event');
			car_events[methid] ? car_events[methid].call(this, othis, e) : '';
			return false;
			cancelBubble ();
		});
	}
}

var car_events = {
	//事件名
	export_list : function (othis,e) {
	      console.log(othis)
	}
}
原文地址:https://www.cnblogs.com/wmt-kilig/p/13993719.html