โ 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. Use document.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>
Topics:
HTML DOM
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.