how to check SVG type in js

SVGSVGElement & SVGElement


svg = document.querySelector(`svg`);
// <svg class=​"icon" style=​"width:​ 100px;​ height:​ 100px;​vertical-align:​ middle;​fill:​ currentColor;​overflow:​ hidden;​" viewBox=​"0 0 1024 1024" version=​"1.1" xmlns=​"http:​/​/​www.w3.org/​2000/​svg" p-id=​"3949">​…​</svg>​ typeof svg;
// "object" Object.prototype.toString.call(svg);
// "[object SVGSVGElement]" svg instanceof SVGSVGElement;
// true
svg instanceof SVGElement;
// true svg instanceof SVGAElement;
// false
svg instanceof HTMLElement;
// false
svg = document.querySelector(`svg`);
// <svg class=​"icon" style=​"width:​ 100px;​ height:​ 100px;​vertical-align:​ middle;​fill:​ currentColor;​overflow:​ hidden;​" viewBox=​"0 0 1024 1024" version=​"1.1" xmlns=​"http:​/​/​www.w3.org/​2000/​svg" p-id=​"3949">​…​</svg>​ typeof svg
// "object" Object.prototype.toString.call(svg);
// "[object SVGSVGElement]" svg instanceof SVGSVGElement;
// true

Web API

SVG DOM interfaces

https://developer.mozilla.org/en-US/docs/Web/API/SVGSVGElement

https://developer.mozilla.org/en-US/docs/Web/API/SVGAElement

https://developer.mozilla.org/en-US/docs/Web/API/SVGElement

SVG

https://developer.mozilla.org/en-US/docs/Glossary/SVG

https://developer.mozilla.org/en-US/docs/Web/SVG

https://developer.mozilla.org/en-US/docs/Web/SVG/Element

https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg

js type checker

https://ioliu.cn/2016/judgment-variable-type/

refs



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


最新文章

  1. 配置opencv时计算机显示丢失opencv_world300d.dll如何解决
  2. 使用Safari远程调试iOS设备网页
  3. HTML中head头结构
  4. Restfull API 示例
  5. ANDROID_MARS学习笔记_S01_004dpi、dp(dip)及计算
  6. 别做操之过急的”无效将军”,做实实在在的”日拱一卒” zz
  7. python中跟字符串相关的一些操作
  8. HttpRequest 类
  9. linux文件 特殊权限的使用
  10. ELK + Filebeat 日志分析系统
  11. 初次接触Linux
  12. 理论篇-MySQL知识汇总
  13. __FILES__
  14. Keepalived基础知识-运维小结
  15. maven配置本地仓库通用
  16. html5中audio的详细使用
  17. ios开发之--复制到剪切板
  18. 【LeetCode】75. Sort Colors (3 solutions)
  19. shell基础 -- 基本正则表达式
  20. oracle在drop表时要注意

热门文章

  1. 在Sublime Text 2工具下编辑laravel框架
  2. MySQL常见优化
  3. scala之map,List,:: , +:, :+, :::, +++操作
  4. 2019牛客暑期多校训练营(第七场)F-Energy stones(思维+树状数组)
  5. 1151 LCA in a Binary Tree
  6. 矩阵树定理(Kirchhoff || Laplace)初探——Part 1(无向图计数)
  7. JavaScript——原型
  8. 牛客编程巅峰赛S1第6场 - 黄金&amp;钻石&amp;王者 C.星球游戏 (单源最短路,Dijkstra)
  9. Codeforces Round #515 (Div. 3) B. Heaters (贪心)
  10. linux搭建网站