<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>函数return关键字</title>
<script type="text/javascript">
window.onload = function(){
var input01 = document.getElementById('input01');
var input02 = document.getElementById('input02');
var btn = document.getElementById('btn');
btn.onclick = function(){
var val01 = input01.value;
var val02 = input02.value;
var rs = add(val01,val02);
alert(rs);
}
}
function add(a,b){
var c = parseInt(a) + parseInt(b);
return c;
alert('计算完成')
// return;
}
</script>
</head>
<body>
<input type="text" name="" id="input01">
<input type="text" name="" id="input02">
<input type="button" name="" value="加" id="btn">
</body>
</html>
流程控制语句 根据一定条件来选择执行
语句分类
1.条件判断语句 if...else
2.条件分支语句 switch...case
3.循环语句 for while do...while
网友评论