Single Choice Easy

QWhat would the following JavaScript code produce?

<p id="demo">head</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() 
{
   var x = document.getElementById("demo");
   x.innerHTML = x.attributes[0].isId;
}
</script>

ID: #5100 Javascript DOM & Event Handling MCQ 168 views
Question Info
#5100Q ID
EasyDifficulty
Javascript DOM & Event Handling MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A false
  • B true
  • D undefined
Correct Answer

Explanation

If an attribute is of type ID, the isId property returns true; otherwise, it returns false. The DOM attribute object contains it.

Share This Question

Challenge a friend or share with your study group.