//Function for Adding Attribute(s) to HTML Elements. function setAttributes( element , attributes ) { for (const key in attributes) { element.setAttribute(key , attributes[key]); } } //Using SetAttributes Function to add Attributes. setAttributes( imgElement , { href : 'https://www.unsplash.com/pictures..', target : '_blank' }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter