JSFiddle - React, Tailwind, and code Playground

by Sukanya Halder

HTML

<div></div>
<div></div>
<div></div>

CSS

div {
    height:100px;
    width:600px;
    
    position:relative;
    padding:2px;
}

JavaScript

$(document).ready(function () {
    $("body").click(function () {
       // generateRandomNumber($(this));
    });
    $("div").on("mouseenter",function(){
         generateRandomNumber($(this));
    });

    function generateRandomNumber(obj) {
        var b = (parseInt((Math.random() * 1000), 10) % 255).toString(16),
            g = (parseInt((Math.random() * 1000), 10) % 255).toString(16),
            r = (parseInt((Math.random() * 1000), 10) % 255).toString(16);
        //console.log("#"+r+g+b);
        obj.css("background-color", "#" + r + g + b);

    }

});