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 event is triggered when a user clicks on an HTML element?
A). click
B). hover
C). submit
D). change
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 change the background color of an HTML element based on user actions using JavaScript?
A). Use event listeners like addEventListener to detect user actions and update the element's background color
B). Use inline JavaScript in the HTML element's onclick attribute to change the background color
C). Use the onHover event directly in the HTML element's tag to change the background color
D). Use the element.background = 'color'; property in JavaScript to directly modify the element's background color
How can you change the font size of an HTML element using JavaScript?
A). element.style.fontSize = '16px';
B). element.style.font = '16px';
C). element.fontSize = '16px';
D). element.font = '16px';
How can you remove an HTML element from the DOM using JavaScript?
A). element.remove()
B). element.removeChild()
C). element.delete()
D). document.removeElement(element)
How can you dynamically change the CSS style of an HTML element using JavaScript?
A). Use the style property of the element to modify CSS styles
B). Use the setStyle() method to apply CSS styles to the element
C). Use inline CSS within the HTML element's tag to specify styles
D). Use external CSS files and link them to the HTML document
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';
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