问题:
I need a way to determine the type of an HTML element in JavaScript.我需要一种方法来确定 JavaScript 中 HTML 元素的类型。 It has the ID, but the element itself could be a <div>
, a <form>
field, a <fieldset>
, etc. How can I achieve this?它有 ID,但元素本身可以是<div>
、 <form>
字段、 <fieldset>
等。我怎样才能做到这一点?
解决方案:
参考一: https://stackoom.com/question/149e参考二: How can I determine the type of an HTML element in JavaScript?