Creating time lag before a change of text

by Akram kamal

HTML

<div id="x"></div>

JavaScript

$.fn.delayedText = function(text,delay) {
    var that = this
    setTimeout(function(){
        that.text(text)
    },delay)
    return that
}


$(function(){
    
    $("#x").text("Hello").delayedText("There",1000).delayedText("Newbie!",2000)
})