Switch between text on button every second


/ Published in: jQuery
Save to your folder(s)

Switch between text on button every second


Copy this code and paste it in your HTML
  1. var timer = setInterval(switchText,1000);
  2.  
  3. var st = 1;
  4. function switchText(){
  5. if(st==1){
  6. $('#button').text("Text2");
  7. st=2;
  8. }else{
  9. $('#button').text("Text1");
  10. st=1;
  11. }
  12. }
  13.  
  14. HTML
  15.  
  16. <div id="button">Text1</div>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.