jcadima
7/19/2017 - 2:04 PM

Change Button text every 1 second

Change Button text every 1 second



<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title></title>

  <link rel="stylesheet" href="css/main.css">
</head>

<body>

	 <button id="button">Text1</button>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
  <script>
  	
 var timer = setInterval(switchText,1000);
 
var st = 1;
function switchText(){
  if(st==1){
    $('#button').text("Text2");
    st=2;
  }else{
    $('#button').text("Text1");
    st=1;
  }
}
 	
  </script>
</body>

</html>