|
|
1
15
https://developer.mozilla.org/en/DOM/document.getElementsByClassName E:在IE<9中本机不受支持,因此您必须使用如下内容扩展文档/生成全局函数: http://robertnyman.com/2008/05/27/the-ultimate-getelementsbyclassname-anno-2008/ 或者用类似的东西 sizzle 或 jquery -感谢下面的评论。 |
|
|
2
14
许多解决方案都是针对没有本机的浏览器而构建的。
例如,使用jquery:
返回具有类的所有DOM元素
如果您只想解决这个特定的问题,而不想使用完整的库,您可以尝试使用类似 The Ultimate GetElementsByClassName ,这样您就可以:
虽然它有几年的历史, John Resig's comparison of various solutions 对于这个问题仍然是有价值的。 |
|
|
3
3
使用GWTQue: http://code.google.com/p/gwtquery/ |
|
|
4
2
使用可能更明智
看看这里: https://developer.mozilla.org/docs/Web/API/document.querySelector https://developer.mozilla.org/docs/Web/API/document.querySelectorAll |