JavaScript为什么我相加的是字符串链接而不是数字相加?
<html><head><scriptlanguage="JavaScript">functionPuls(){varaddend=document.getElement...
<html>
<head>
<script language="JavaScript">
function Puls()
{
var addend = document.getElementById("addend").value;
var summand = document.getElementById("summand").value;
var count = addend + summand;
var puls = "加数:" + addend + "被加数:" + summand + "结果:" + count;
alert(puls);
}
</script>
</head>
<body>
<form id="fm">
<h1>加法运算</h1>
加数:<input type="text" id="addend">
被加数:<input type="text" id="summand">
<input type="button" value="运算" onclick="Puls()">
</form>
</body>
</html> 展开
<head>
<script language="JavaScript">
function Puls()
{
var addend = document.getElementById("addend").value;
var summand = document.getElementById("summand").value;
var count = addend + summand;
var puls = "加数:" + addend + "被加数:" + summand + "结果:" + count;
alert(puls);
}
</script>
</head>
<body>
<form id="fm">
<h1>加法运算</h1>
加数:<input type="text" id="addend">
被加数:<input type="text" id="summand">
<input type="button" value="运算" onclick="Puls()">
</form>
</body>
</html> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询