function onReady() { $(`p>img`) .after(appendExpandButton) .next() .on('click', onExpandButton); $(`#expand-img button`).on(`click`, onHideImgExpand); } function appendExpandButton(img) { return `+` } function onExpandButton(e) { var imgSrc = this.getAttribute(`data-img`); $(`#expand-img img`).attr(`src`, imgSrc); $(`#expand-img`).show(0); } function onHideImgExpand() { $(`#expand-img`).hide(500); } (function() { $(document).ready(onReady) })()