← Back to HTML DOM
Question 17
Create Image Element with Attributes
Create Image Element with Attributes
Create a new image element and set its src to "photo.jpg" and alt to "My Photo". Then append it to the div with id="imageContainer". Platform-Provided HTML (READ-ONLY):<div id="imageContainer"></div>Steps: 1. Usedocument.createElement()to create a new<img>element 2. Set its src attribute to "photo.jpg" 3. Set its alt attribute to "My Photo" 4. Select the container and append the image to it
Expected Output:
<div id="imageContainer"> <img src="photo.jpg" alt="My Photo"> </div>
= newline. No newline after the last line.
Hints4 available
Sign in to use hintsTopics:
HTML DOM
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (clog, fn, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.