Answers for "how to check in js if element is li or is button"

0

how to check in js if element is li or is button

// use attribute .tagName, which returns a type e.g. DIV, BUTTON, LI etc.
const functionName = () => {
	if(e.target.tagName == 'BUTTON') {
    console.log("It's a button";
	} else {
	    console.log("It's not a button");
	}
}

// if you prefer: function functionName (params) {action} instead of "e.target" use this
Posted by: Guest on May-25-2021

Code answers related to "how to check in js if element is li or is button"

Code answers related to "Javascript"

Browse Popular Code Answers by Language