Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在 document.body.oncopy 上执行一个函数,但是有一个特定的类(定义为 div 元素),我不想在其上调用这个函数。
有没有办法做到这一点?
正如我在评论中所说,您可以执行以下操作:
document.body.addEventListener('copy', function (e) { if (e.target.className === 'specific') { return; } // Continue with all permitted elements }