Posted By

envane21 on 07/26/16


Tagged

text button Switch between on second every


Versions (?)

Switch between text on button every second


 / Published in: jQuery
 

Switch between text on button every second

  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  

You need to login to post a comment.