how to check SVG type in js
2024-10-19 06:46:27
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 发布文章使用:只允许注册用户才可以访问!
最新文章
- 配置opencv时计算机显示丢失opencv_world300d.dll如何解决
- 使用Safari远程调试iOS设备网页
- HTML中head头结构
- Restfull API 示例
- ANDROID_MARS学习笔记_S01_004dpi、dp(dip)及计算
- 别做操之过急的”无效将军”,做实实在在的”日拱一卒” zz
- python中跟字符串相关的一些操作
- HttpRequest 类
- linux文件 特殊权限的使用
- ELK + Filebeat 日志分析系统
- 初次接触Linux
- 理论篇-MySQL知识汇总
- __FILES__
- Keepalived基础知识-运维小结
- maven配置本地仓库通用
- html5中audio的详细使用
- ios开发之--复制到剪切板
- 【LeetCode】75. Sort Colors (3 solutions)
- shell基础 -- 基本正则表达式
- oracle在drop表时要注意
热门文章
- 在Sublime Text 2工具下编辑laravel框架
- MySQL常见优化
- scala之map,List,:: , +:, :+, :::, +++操作
- 2019牛客暑期多校训练营(第七场)F-Energy stones(思维+树状数组)
- 1151 LCA in a Binary Tree
- 矩阵树定理(Kirchhoff || Laplace)初探——Part 1(无向图计数)
- JavaScript——原型
- 牛客编程巅峰赛S1第6场 - 黄金&;钻石&;王者 C.星球游戏 (单源最短路,Dijkstra)
- Codeforces Round #515 (Div. 3) B. Heaters (贪心)
- linux搭建网站