window.onload = function(){alert(2)}

	function addEvent (fun) {
var old = window.onload; if(typeof old != "function"){
window.onload = fun;
}else{
window.onload = function(){
old();
fun();
}
}
} function delegationforli(){
var oul = document.getElementsByTagName('ul')[0];
console.log(oul)
oul.addEventListener('click',function(e){
console.log(e.target);
if(e.target && e.target.nodeName.toLowerCase() == 'li'){
alert(e.target.innerHTML);
}
})
}
addEvent(delegationforli);

用这种window.onload =function() { t();  b(); }方法函数的时候会看着很不爽,可以用上面的方法,更易读。

最新文章

  1. intellij idea使用
  2. codeforces B - Preparing Olympiad(dfs或者状态压缩枚举)
  3. POJ 3259 Wormholes (判负环)
  4. phaser
  5. [转]开源中国的 IT 公司开源软件整理计划介绍
  6. 识货的拿走:Android游戏框架解读之总体结构
  7. ios UICollectionView滑动时操作
  8. python auto send email
  9. GA遗传算法解析
  10. 【解决】Maven myeclipse出现Could not find the main class
  11. STL-空间配置器(allocator)
  12. CII-原子
  13. Apache Curator入门实战
  14. mysql安装和配置(windowns||centos)
  15. 自动生成 java 测试 mock 对象框架 DataFactory-01-入门使用教程
  16. How to change system keyboard keymap layout on CentOS 7 Linux
  17. postman笔记1--postman的安装教程
  18. Parsing error was found in mapping #{}. Check syntax #{property|(expression), var1=value1, var2=val错误
  19. Spring Data Redis 详解及实战一文搞定
  20. git命令详解( 二 )

热门文章

  1. iOS 日志系统 本地日志打包上传到服务器
  2. SQL之经典语句
  3. C#趣味程序---理財高手
  4. Redis源码阅读-Dict哈希字典
  5. wps文档怎样去除广告
  6. python selenium2示例 - email发送
  7. ubuntu 1204 安装mysql
  8. XtraBackup全备与增量备份
  9. history命令使用方法详解
  10. Zabbix 监控tomcat web