JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" class="text" /> <input type="text" class="text2" />
CSS
.text,.text2{
outline: none;
}
JavaScript
//Эту часть к скриптам
$.fn.valid = function(opt,foo){
var me = $(this),
timeOut = true,
option = {
time : 500
};
if(typeof opt == "object") $.extend(option,opt) ;
if(typeof opt == "function") foo = opt ;
me.on("keyup",function(){
clearTimeout(timeOut);
$elem = this
timeOut = setTimeout(function(){
if(typeof foo == "function") foo.call($elem);
},option.time)
})
}
//Это подключение
$(".text").valid({time : 1000},function(){
// Здесь что будет происходить
var rand = 0 + Math.random() * (20 - 0)
rand = Math.round(rand);
$(this).css({"border-top-right-radius" : rand + "px"})
})
//Можно несколько
$(".text2").valid({time : 1000},function(){
var rand = Math.round(0 + Math.random() * (255 - 0)),
rand1 = Math.round(0 + Math.random() * (255 - 0)),
rand2 = Math.round(0 + Math.random() * (255 - 0));
$(this).css({"background" : "rgba(" +rand + "," + rand1 + "," + rand2 + "," + Math.random() + ")"})
})