-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
一个淘宝页面,你如何取得这个页面用到哪几种标签? #22
Comments
遍历整个DOM树,判断它的nodeType === 11吧?然后取它的nodeName还是tagName,就可以了吧? |
nodeType到底是不是11,我不是太确定。。应该是11,11是表示element节点 |
@henryzp 同一个回答建议不要分为两层楼啊。可以编辑自己原来的回答。
|
document.getElementsByTagName('*') 咋没人说这个 |
@leegedan 不错。等价于document.all。在一些禁用document.all的页面下可以使用 |
简单写一下,可能还需要修改:
|
@guol-talend 嗯,可以的。看到一个语句顺便说一下☟ var a=[]; var b=new Array(125624);
a.push.apply(a,b)
|
@giscafer 谢谢提醒, 发现的一个stackoverflow 贴 ^_^ |
Array.from(new Set(Array.from(document.querySelectorAll('*')).map(({tagName})=> tagName.toLowerCase()))) |
|
function getAllTypes() { |
[...new Set([...document.all].map(function(ele){if(ele.nodeType === 1){return ele.nodeName}}))]; |
Array.from(document.getElementsByTagName('*')).map((each)=>each.tagName).filter((each,index,array)=>array.indexOf(each)==index) |
function getTagsOfNode(node, result = []) { |
后边来的同学,不用继续回复了,自己写写和看看楼上各位答案就够了。最佳答案在@Jiasm |
考点Dom基础,来自贺老知乎live
The text was updated successfully, but these errors were encountered: