Question
Javascript to show text for a specified duration (in milliseconds)
I am trying to use Javascript to show text for a specified duration (in milliseconds). I want the question to remain, but the text hidden after the time elapses. However, the code is not working. Can someone help please?
//flash single text for specified duration
var text = "Write text to be displayed here";
var time = 1500; //time in milliseconds
var c = this.questionContainer;
var tc = QBuilder('span',{},text);
$(tc).setStyle({color:'red',fontSize:'24pt'}); //optional to change text style
var ic = QBuilder('div',{},[tc]);
$(c).appendChild(ic);
(function(){
$(ic).clonePosition(tc); //comment this line out to remove the white space left after the
text is hidden
$(tc).hide();
}).delay(time/1000);
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.