Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Web technologies Questions | JavaScript Course Quiz 1 | Question 10

  • Last Updated : 10 May, 2019

What is the correct JavaScript syntax to change the content of the HTML element below?




<p id="demo">May the code be with you.</p>

(A) document.getElementById(“demo”).innerHTML = “Hola!”;
(B) document.getElement(“p”).innerHTML = “Hola!”;
(C) #demo.innerHTML = “Hola!”;
(D) document.getElementByName(“p”).innerHTML = “Hola!”;


Answer: (A)

Explanation: The getElementById() method of DOM(Document) will return the element that has the ID attribute with the specified value declared in the braces. After getting the element we can change its HTML by using the innerHTML function of the Javascript.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :