logo

What is the output that is printed when the div containing the text "Click Here" is clicked?
//HTML Markup
<div id="A">  <div id="B">    <div id="C">Click Here</div>  </div></div>
//JavaScriptdocument.querySelectorAll('div').forEach((e) => {
  e.onclick = (e) => console.log(e.currentTarget.id);});

What is the output that is printed when the div containing the text "Click Here" is clicked?

//HTML Markup
<div id="A">  <div id="B">    <div id="C">Click Here</div>  </div></div>
//JavaScriptdocument.querySelectorAll('div').forEach((e) => {
  e.onclick = (e) => console.log(e.currentTarget.id);});

题目类型: 技术面试题

这是一道技术面试题,常见于澳洲IT公司面试中。

难度: medium

分类: JavaScript

标签: JavaScript

参考答案摘要

[x] C B A C B A [ ] A A [ ] C C [ ] A B C A B C

本题提供 STAR 原则详细解答和技术解析,登录匠人学院学习中心即可查看完整答案。

← 返回面试题库

What is the output that is printed when the div containing the text "Click Here" is clicked? <pre><code>//HTML Markup &lt;div id=&quot;A&quot;&gt; &lt;div id=&quot;B&quot;&gt; &lt;div id=&quot;C&quot;&gt;Click Here&lt;/div&gt; &lt;/div&gt;&lt;/div&gt;</code></pre> <pre><code>//JavaScriptdocument.querySelectorAll(&#x27;div&#x27;).forEach((e) =&gt; { e.onclick = (e) =&gt; console.log(e.currentTarget.id);});</code></pre>

Mediumjavascriptweb-development

想查看完整答案?

登录匠人学院学习中心,获取 STAR 格式回答和详细技术解析

前往学习中心查看答案