Podcast
Questions and Answers
What is the purpose of the 'swapText' function defined in the given JavaScript code snippet?
What is the purpose of the 'swapText' function defined in the given JavaScript code snippet?
- To change the text of an element with id 'output' to 'Bye' (correct)
- To create a new text element with the content 'Bye'
- To trigger an event when 'Hello' is clicked
- To swap the positions of two elements on the webpage
What does the following JavaScript statement achieve: 'var text = document.getElementById("output");'?
What does the following JavaScript statement achieve: 'var text = document.getElementById("output");'?
- It creates a new HTML element with id 'output'
- It retrieves the element with id 'output' from the DOM (correct)
- It hides the element with id 'output'
- It sets the text content of the element with id 'output' to a variable named 'text'
In JavaScript, what does the 'innerHTML' property do when used with an element?
In JavaScript, what does the 'innerHTML' property do when used with an element?
- Adds a new child element inside the selected element
- Changes the background color of an element
- Modifies the CSS styling of an element
- Sets or returns the HTML content (inner HTML) of an element (correct)