function low(){ var data = document.getElementById("msg").value; var number = Math.floor(Math.random()*41)-20; data+=number; var result = document.getElementById("msg"); result.innerHTML = data; } script>
5楼不都给你写出来了么 222 var data = document.getElementById("msg").value //data的值为111 var data = document.getElementById("msg").innerHTML //data的值为222
如果非要用它,那么应该是innerText, 最好还要转成数字
无标题文档
function low(){ var data = parseInt(document.getElementById("msg").innerText); var number = Math.floor(Math.random()*41)-20; data += number; var result = document.getElementById("msg"); result.innerHTML = data; } script>