function abc(elm){
this.$elm = document.querySelector(elm)
}
abc.prototype.addClass = function (str){
this.$elm.classList.add(str)
return this
}
abc.prototype.removeClass = function (str){
this.$elm.classList.remove(str)
return this
}
abc.prototype.delay = function (timer){
let self = this
setTimeout(()=>{
return self
},timer)
return this
}
function $(str){
return new abc(str);
}
let x = $('#test').delay(5000).delay(1000).addClass('red');
console.log($('#test'));
I want to add red
class after 6
secs.I tried like using setTimeout but not work.could you please suggest the better way ?
I want to write a delay function which delay for sometime before proceeding/executing next code.