JSFiddle - React, Tailwind, and code Playground

by villard

HTML

<div id="test">
    <div class="t1">CLICK</div>
    <div class="t2">$(this).stop().animate({width:"0px"},1000);</div>
</div>

CSS

#test {
	width: 120px;
	height: 300px;
	background-color: red;
	position: relative;
}

.t1, .t2 {
    position: absolute;
    left: 0;
    top: 0;
}

.t1 {
	width: 50px;
	height: 50px;
	background-color: black;
    z-index: 20;
    color:white;
}

.t2 {
	width: 0px;
	overflow: hidden;
	height: 50px;
	background-color: pink;
    z-index: 10;
    white-space: nowrap;
}

JavaScript

$(document).ready(function() {
				$('.t1').mouseenter(function () {
			        $(this).next().stop().animate({width: "550px"},1000)

			    }).mouseleave(function () {
			        $(this).next().stop().animate({width: "0px"},1000);
			    });

			    $('.t2').mousemove(function() {
						$(this).stop().animate({width:"550px"},1000)
					});
					
				$('.t2').mouseout(function() {
						$(this).stop().animate({width:"0px"},1000);
					}); 

			});