我想限制这个选择器,只给我一个 id 为“divId1”的 div 内部的结果
var polys = document.querySelectorAll('polygon,polyline');
我怎样才能做到这一点?
最佳答案
试试空间运算符:
var polys = document.querySelectorAll('#divId1 polygon, #divId1 polyline');
See MDN's page on selectors了解更多。
关于javascript - querySelectorAll - 如何只获取某个 div 中的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18404211/