Created
May 20, 2012 08:57
-
-
Save simplelife7/2757417 to your computer and use it in GitHub Desktop.
【JS】在外层元素监听事件
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 使用事件代理,在更外层的元素上监听事件 | |
| document.getElementById('list').onclick = function(evt){ | |
| var evt = evt || window.event, | |
| target = evt.target || evt.srcElement; | |
| if(target.id === 'btn1'){ | |
| // do something | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment