JSFiddle - React, Tailwind, and code Playground

by bigua

HTML

<body>
    <div id="slider" data-wjs-element="box"></div>
    <div id="box"></div>
    <div id="box2">
        <p>Fade with the above slider...</p>
    </div>
</body>

CSS

#box {
        width: 200px;
        height: 200px;
        background-color: #ff0000;
        position: absolute;
    }
    #slider {
        width: 200px;
    }
    #box2 {
        width: 200px;
        height: 200px;
        position: absolute;
    }

JavaScript

$(document).ready(function () {
        //Step 1: set up the slider with some options. The valid values for opacity are 0 to 1
        //Step 2: Bind an event so when you slide the slider and stop, the following function gets called
        $('#slider').slider({
            min: 0,
            max: 1,
            step: 0.01,
            value: 1,
            orientation: "horizontal",
            slide: function (e, ui) {
                $('#box').css('opacity', ui.value)

            }
        })
    });