| 1 min read

我们经常通过事件代理会取到一些元素,大概我们第一个想到的 tagName 来判断,但是这样的确需要写过 map 来判断。我们可以有个快捷的方法:

const el = document.querySelector('.svg-inner');
el.ownerSVGElement // true 则表示式 svg 元素 如果 false 则不是

参考: https://stackoverflow.com/questions/20748836/how-do-i-tell-if-a-dom-element-is-html-or-svg#=

You Can Speak "Hi" to Me in Those Ways