|
|
|
|
|
by heyrhett
5469 days ago
|
|
I'll use anything that fixes the way javascript handles scoping. Take this gem, for example: <html>
<body>
<ul>
<li>First</li>
<li>Second</li>
<li>Third</li>
<li>Fourth</li>
</ul>
</body> <script type="text/javascript">
els = document.getElementsByTagName('li');
for(i=0; i < els.length; i++){
els[i].addEventListener('click', function(){alert(i);}, false);
}
</script>
</html> |
|