JSFiddle - React, Tailwind, and code Playground

by D S

HTML

<div class="demo">123</div>
<div class="item">data</div>

JavaScript

function some_function(arg1, arg2, callback) {
	// this generates a random number between
	// arg1 and arg2
	var my_number = Math.ceil(Math.random() *
		(arg1 - arg2) + arg2);
	// then we're done, so we'll call the callback and
	// pass our result
	callback(my_number);
}
// call the function
some_function(5, 200, function(num) {
	// this anonymous function will run when the
	// callback is called
	$(".demo").text(num);
    
});

function transfer(item, callback) {
	var my_number = 21;
    console.log("1");
	callback(my_number);
    
}
transfer(5, function(num) {
	$(".item").text(num);
    console.log("2");
});