JSFiddle - React, Tailwind, and code Playground

by Denis Minov

HTML

<input type="text" id="apoinput" value="http://pw5.ddns.info/images/pw5_ddns_info/mjzty2/wxbb3d-pw5_ru-zelen-vid-prekrasno-chistota.jpg" />
<input type="button" id="apook" value="OK" />
<br/>
<br/>
<img class="apoimg" />

CSS

.apoimg {
    width: 400px;
    height: auto;
}

JavaScript

$(document).ready(function() {
    $('#apook').click(function () {
        var a = $('#apoinput').val();
        if(a.indexOf('.jpg') != -1 || a.indexOf('.jpeg') != -1 || a.indexOf('.png') != -1 || a.indexOf('.gif') != -1) {
            $('.apoimg').style.backgroundImage = "url('a')";
        };
    });
});