Open In App

Web technologies Questions | JavaScript Course Quiz 1 | Question 10

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

Article Tags :