JSFiddle - React, Tailwind, and code Playground

by Mike Gifford

HTML

<div id="container"></div>

JavaScript

var div = document.createElement('div');

// Define image
var img = document.createElement('img');
img.src = 'https://www.google.fr/images/srpr/logo3w.png';
img.alt = "Alternative text";

// Define link
var anchor = document.createElement('a');
anchor.href = 'http://google.com';
anchor.title = 'Googly Googly Googly';

// Wrap image in the link (anchor):
anchor.appendChild(img);

// Insert the anchor into container:
div.appendChild(anchor);

document.getElementById('container').appendChild(div);