I need help adjusting a javascript that places an image tag dynamically inside another tag.
This is what I’m using:
`<p id=”placed-image”></p>
<script type=”text/javascript”>
var img = document.createElement(“img”);
img.src = “
img.alt = “Adorable Kitten”;
var src = document.getElementById(“placed-image”);
src.appendChild(img);
</script>
`
It works great but I need to use a “class” and not an “id” for the container tag.
I’ve tried replacing “getElementById” with “getElementsByClassname” but it doesn’t work.
Any help would be appreciated.
Thank you.