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)
	}
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM