这个主要会用在表单字段中,所以我这里做的实验只针对表单字段。在form的子元素中循环查找第一个不是隐藏字段的字段,然后使用focus方法获得焦点。(呵呵^_^,很简单!)
FormUtil.focusOnFirst = function() {
if (document.forms.length > 0) {
for (var i = 0; i var oField = document.forms[0].elements[i];
if (oField.type != "hidden") {
oField.focus();
return;
}
}
}
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn