js事件绑定简单写法

$E.on = function (o, e, f) {
	return o.addEventListener ? o.addEventListener(e, f, false) : o.attachEvent('on'+e, function () { f.call(o) });
};

$E.on(document.getElementById('dele-ul'), 'click', function (e) {
	var tar = e.target || e.srcElement;
	if (tar.nodeName.toLowerCase() == 'li') {
		alert(tar.innerHTML);
	}
})
posted @ 2014-02-06 15:23  xiezhenzhong  阅读(278)  评论(0编辑  收藏  举报