<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta charset="utf-8" /> <meta name="referrer" content="never"> <title>Title</title> </head> <body> <h1>GitHub Emojis API</h1> <h4> <a href="https://api.github.com/emojis">https://api.github.com/emojis</a> </h4> <button id="btnLoad">Load Emoji</button> <ul id="ubox"></ul> </body> </html>
#ubox { padding: 0; } #ubox li { float: left; list-style: none; } #ubox li img { margin: 15px; max-width: 48px; } #ubox li div { width: 100%; text-align: center; white-space: nowrap; }
document.getElementById('btnLoad').onclick = function () { fetch('https://api.github.com/emojis') .then(response => response.json()) .then(data => { var htm = []; for (var i in data) { htm.push('<li><img title="' + i + '" src="' + data[i] + '" /></li>'); } document.getElementById('ubox').innerHTML = htm.join(''); }); }