📜  如果元素是 li 或者是按钮,如何签入 js - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:58.245000             🧑  作者: Mango

代码示例1
// 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