IE与现代浏览器兼容性获取类名
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>IE与现代浏览器兼容性获取类名</title> </head> <body> <script> function getClass(classname,obj){ var arr=[]; var obj1=obj||document; if(document.getElementsByClassName){ return obj1.getElementsByClassName(classname); }else{ var all=obj1.getElementsByTagName('*'); for(var i=0;i<all.length;i++){ if(all[i].className==classname){ arr.push(all[i]); } } return arr; } } var length=getClass('inner').length; </script> </body> </html>
posted on 2017-05-17 14:23 skylark_one 阅读(108) 评论(0) 编辑 收藏 举报