![](/img/trans.png)
[英]How to find whether an element is hidden or not in html and pure javascript
[英]Find element in array of HTML element with pure Javascript
单击我的元素后,我可以显示路径:
console.log(e.path)
这给了我一个数组:
[i.fi.fi-bubble, button.c-block, div, body.u-help, html, document, Window]
我想在此数组中查找是否存在带有纯Javascript类“ c-block”的元素
你有什么建议吗?
谢谢
使用以下代码:-
<script>
var array = ["i.fi.fi-bubble", "button.c-block", "div", "body.u-help", "html", "document", "Window"];
var index = array.filter(value => /c-block/.test(value));
console.log(index.length);
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.