biaoge's blog

以前端技术为主

Archive for the ‘event’ tag

《精通javascript》中的几个错误

with 4 comments

第86页,代码清单5-28中有这样一段:

//向后遍历数组,
//因为我们向前添加元素
for ( var i = elems.length - 1; i >= 0; i-- ) {
    parent.insertBefore( elems[i], before );
}

此处用一个反循环反而把被添加元素的顺序搞反了,用一个正循环才能得到正确的顺序。

另一个错误:在103页,表单事件那部分有这样一句:“select事件在<select>元素更新后触发”。事实上,<select>元素更新后只会触发onchange事件,不会触发onselect事件,参见这里:“Broadly speaking, buttons can generate click events, and text and select items can generate focus, blur, select, and change events. The one potentially confusing aspect of this organization of events is that selection lists cannot generate the select event. This is because they have no editable text. ”

Written by admin

November 16th, 2008 at 12:08 pm

Posted in 前端技术

Tagged with , , ,