Dynamic Img Src Attribute

I’m not sure where to start here. The productName p tag dynamically changes based on a parameter in the URL.

<p id="productName">67</p>

How would I use javascript to dynamcally insert the 67 value into a img src attribute:

<img id="dynamicImg" src="https://cdn2.hubpot.net/hubf/45645/asset-diecu/sampleImage/67_a.png"/>

20 thoughts on “Dynamic Img Src Attribute”

Leave a Comment