首页
登录 | 注册

如何用getElementById选择多个标签?

<div id = 'DIV' class = 'className'>1</div> <div id = 'DIV'>2</div> <div id = 'DIV'>3</div> <script language="JavaScript"> <!-- document.getElementsById = function(id) { if (typeof(id) == 'string') { var all = document.getElementsByTagName('*'); var length = all.length; var elements = []; while (length) { if (all[--length]['id'] == id) { elements.unshift(all[length]) } } return elements.length == 0 ? null : elements.length == 1 ? elements[0] : elements } return null } alert( document.getElementsById('DIV') ) //--> </script>



2020 jeepxie.net webmaster#jeepxie.net
10 q. 0.008 s.
京ICP备10005923号