js records the number of times a button is clicked refresh times are instances of the initial state

  • 2021-07-21 07:09:41
  • OfStack

Examples are as follows:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/javascript; charset=utf-8" /></head>
<body>
<input type="button" value=" Click " onclick="checkRight()" />
 Number of times counted: 
<span id="dianjicishu"></span>
</body>
<script defer="defer">
  var x=0;
  function checkRight(){
     x=x+1;
     document.getElementById('dianjicishu').innerHTML = x;
  }
</script>
</html>

Related articles: