JSFiddle - React, Tailwind, and code Playground

HTML

<div class="background">
    <img id="background" src="https://www.gravatar.com/avatar/8e4dd8ae2d6385e4c857861c98b4f3ee?d=wavatar&s=60" />
</div>

JavaScript

$('#background').each(function() {
    var image = $(this).attr('src');

    $(this)
        .parents('.background')
        .css({
            "display": 'inline-block',
            "background": 'url(' + image + ')',
            "height": '100px'
        })
        .html('Картинка применена как background');
});