Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test if object is a DOM element

A JavaScript function receives one argument that may be a DOM element or not. How ensure that argument is a DOM element and not another object?

like image 593
Frankly Avatar asked Mar 10 '26 01:03

Frankly


1 Answers

With modern browsers I think it is something like

e instanceof Element
e instanceof Text // text node
like image 66
Leonid Avatar answered Mar 11 '26 15:03

Leonid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!