JSFiddle - React, Tailwind, and code Playground

by Marco

HTML

<div id="text">Samples</div>
<button id="sc">Click Me</button>

JavaScript

$(document).ready(function(){
	$.fn.scramble = function(){
		var str=$(this).text()
		function recursor(str){
			if(str.length>=3){
				var result = str.substring(1, str.length-1);
				$('#text').append(' '+result)
				setTimeout(function() { recursor(result) },1000)
			 }
		}
		recursor(str)
	}
	$('#sc').click(function(){
		$('#text').scramble()
	})	
})