Answers for "js find type of element"

2

how to know type of dom element in js

let divElement = document.createElement('div');

if (divElement.nodeName == "DIV") //true
if (divElement.nodeName == "<div>") //false
Posted by: Guest on June-17-2020
1

js get element type

// Use the DOM element's 'tagName' property:

var element_type = field.tagName;
Posted by: Guest on January-29-2021
6

javascript find type of variable

> typeof "foo"
"string"
> typeof true
"boolean"
> typeof 42
"number"

if(typeof bar === 'number') {
   //whatever
}
Posted by: Guest on May-16-2020
12

check data type in javascript

typeof("string"); //string
typeof(123); //number
Posted by: Guest on July-25-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language