首页题目详情

以下哪项代码是正确使用事件对象的示例?

题目配图
A.element.onclick = function() { console.log(event.target); }
B.element.addEventListener('click', function() { console.log(event.type); })
C.element.onmouseover = function(event) { console.log(event.srcElement); }
D.以上所有选项都正确。

优质解答

答案

D

解析

所有选项都展示了正确使用事件对象的方式。A使用了onclick事件的默认处理方式,B使用了addEventListener绑定,C使用了onmouseover并传递了event对象。因此D选项正确。

查看答案和解析

支付 ¥0.1 即可查看此题答案和详细解析

低至 ¥0.1 起

Web程序设计单选题中等AI生成