就是在js里写了个变量,值为0
怎么在html里把变量值改成1
<button onclick="set()">方法一、改变变量的值</button>
<button onclick="javascript:num = 1;show();">方法二、改变变量的值</button>
<span></span>
<script type="text/javascript">
var num = 0;
show();
function set(){
num = 1;
show();
}
function show(){
document.getElementsByTagName('span')[0].innerHTML = num;
}
</script>追问
<button onclick="javascript:num = 1;show();">方法二、改变变量的值</button>
<span></span>
<script type="text/javascript">
var num = 0;
show();
function set(){
num = 1;
show();
}
function show(){
document.getElementsByTagName('span')[0].innerHTML = num;
}
</script>追问
方法一怎么写
温馨提示:答案为网友推荐,仅供参考