是否可以通过单击来将 DOM 元素识别为唯一元素,然后通过 jquery ReplaceWith 方法对其进行更改?
最佳答案
您可以使用事件对象的 target
属性来识别单击的元素。
addEventListener("click", event => {
const element = event.target;
console.log(element);
// Now do whatever you like with the element
});
<button>a</button>
<button>b</button>
<button>c</button>
<button>d</button>
<button>e</button>
关于javascript - 是否可以将 DOM 元素标识为唯一?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53175201/