请帮助我。我有一个按钮,我想创建一个操作,这样,每当单击该按钮时,就会将100添加到特定div中的值。另外,我不希望刷新页面时div中的值恢复到以前的值。
<h4>Activity Earnings:<h4><br>
<h4 id="demo"> 0 </h4>
<button onclick="myFunction(whatever number
that
is met in the demo's value, 100)">earn</button>
<script>
function myFunction(the number met in the
demo for instance: 0 is currently there, 100) {
x1 = demo's value + 100;
document.getElementById("demo").innerHTML
= x1;
}
</script>