📜  整个可点击 div 内的按钮 onclick - Javascript 代码示例

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

代码示例1
//event.target would help you in this
    if (event.target.className === "delete") {
      console.log("HELLO")
      this.shortcutArray.splice(index, 1);
    }

form.onclick = function(event) {
  event.target.style.backgroundColor = 'yellow';

  // chrome needs some time to paint yellow
  setTimeout(() => {
    alert("target = " + event.target.tagName + ", this=" + this.tagName);
    event.target.style.backgroundColor = ''
  }, 0);
};