問題:
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?