以下不按预期工作:
function sum(x,y){
return x + y;
}
document.getElementById('submit').onclick = function(e)
{
//do someting
e.stopPropagation();
var value1 = document.getElementById('v1').value,
value2 = document.getElementById('v2').value;
var newSum = sum(value1, value2);
console.log(newSum);
}
获取的值有问题。它应该返回总和而不是“1+2=12”