Сообщение от devote
|
как минимум будет работать в 100 раз быстрее
|
А заодно я солью тебя в говнецо, раз уж ты высунулся
<!DOCTYPE HTML>
<html>
<head><meta charset="windows-1251" /> </head>
<body>
<input class="digit" type="text" maxlength="8" name="ot" value="">
<input class="digit" type="text" maxlength="8" name="do" value="">
<script>
get=function(){
var el=document.createElement("input")
el.setAttribute("class", "digit")
document.body.appendChild(el)
}
count=1000
while(count--) get()
digits=document.getElementsByClassName("digit")
func1=function(){alert(1)}
func2=function(){alert(2)}
console.time("for in")
for(i in digits){if(/\d+/.test(i)) digits[i].onkeyup=func1}
console.timeEnd("for in")
console.time("for")
for(var index = digits.length; index--;) {
digits[index].oninput=func2;
}
console.timeEnd("for")
//FF:
//for in: timer started start_page.html:22
//for in: 0ms start_page.html:24
//for: timer started start_page.html:26
//for: 16ms
</script>
</body>
</html>
Другой, нижеотписавшийся "мастер" вообще не стоит внимания.