JSFiddle - React, Tailwind, and code Playground

by envira

HTML

<input type='file' id='getval' name="background-image" onchange="readURL(event)" /><br/><br/>
<div id='clock'></div>

CSS

#clock{
		   background-image:url('');
		   background-size:cover;
		   background-position: center;
		   height: 250px; width: 250px;
		   border: 1px solid #bbb;
			}

JavaScript

function readURL(event){
		 var getImagePath = URL.createObjectURL(event.target.files[0]);
		 $('#clock').css('background-image', 'url(' + getImagePath + ')');
		}