Testing the type of a DOM element in JavaScript

前端 未结 7 1055
孤街浪徒
孤街浪徒 2020-12-13 16:46

Is there a way to test the type of an element in JavaScript?

The answer may or may not require the prototype library, however the following setup does make use of t

7条回答
  •  春和景丽
    2020-12-13 17:15

    if (element.nodeName == "A") {
     ...
    } else if (element.nodeName == "TD") {
     ...
    }
    

提交回复
热议问题