JSFiddle - React, Tailwind, and code Playground

HTML

simple counter:
<button onclick="reduceEvent()">-</button>
<button onclick="addEvent()">+</button>

<hr>

simple calculator:
<input type="text" />
<input type="text" />
<button onclick="count()">加/減/乘/除</button>

JavaScript

let num=0;
function addEvent(){
  num+=1;
  alert(num);
}
function reduceEvent(){
  num-=1
  alert(num);
}


function count(){
  let one=document.querySelectorAll("input")[0].value;
  let two=document.querySelectorAll("input")[1].value;
  one=parseInt(one);
  two=parseInt(two);
  let addition=one+two;
  let subtraction=one-two;
  alert("加法:"+addition);
  alert("減法:"+subtraction);
  alert("乘法:"+parseInt(one)*parseInt(two));
  alert("除法:"+parseInt(one)/parseInt(two));
}