What is the purpose of the innerText property in JavaScript?
A). To set or retrieve the text content of an element, including its descendants
B). To set or retrieve the HTML content of an element, including its descendants
C). To set or retrieve the value of an input element
D). To set or retrieve the URL of an anchor element
What is the purpose of using the innerHTML property in JavaScript?
A). To set or retrieve the HTML content of an element, including its descendants
B). To set or retrieve the text content of an element, including its descendants
C). To set or retrieve the value of an input element
D). To set or retrieve the URL of an anchor element
How can you change the text color of an HTML element using JavaScript?
A). element.style.color = 'blue';
B). element.textColor = 'blue';
C). element.style.textColor = 'blue';
D). element.color = 'blue';
What does the appendChild() method do in JavaScript?
A). Appends a new child node to an existing element in the DOM
B). Removes a child node from an existing element in the DOM
C). Replaces an existing child node with a new node in the DOM
D). Creates a new parent node for an existing child node in the DOM
Which JavaScript method is used to replace one HTML element with another in the DOM?
A). replaceChild()
B). replaceElement()
C). replaceNode()
D). element.replaceWith()
How can you change the background color of an HTML element using JavaScript?
A). element.style.backgroundColor = 'red';
B). element.background = 'red';
C). element.bgColor = 'red';
D). element.color = 'red';
Which JavaScript property is used to change the source (URL) of an image element?
A). src
B). url
C). href
D). source
How can you dynamically add a new paragraph element to an HTML document using JavaScript?
A). document.createElement('p') followed by appendChild()
B). document.getElementById('newParagraph').textContent = 'New Paragraph';
C). document.querySelector('p').innerText = 'New Paragraph';
D). document.innerHTML = '<p>
New Paragraph</p>
';
Which JavaScript method is commonly used to create a new HTML element dynamically?
A). document.createElement()
B). document.appendElement()
C). document.makeElement()
D). document.createNode()
How can you add a CSS class to an HTML element using JavaScript?
A). element.classList.add('className');
B). element.className = 'className';
C). element.style.class = 'className';
D). element.addClass('className');